Zdravím. Dělám si GM a mám problém. Když se hráč zaregistruje nebo přihlásí a spawne se, vidí všechny hráče jako AFK a nevidí jejich pohyb. Myslel jse , že by to mohlo být díky přikazu TogglePlayerControllable, ale když jsem to vymazal, pořád to bylo stejné. Zde je kod.
//=============================================================================> Includes
#include <a_samp>
#include <YSI\y_ini>
//=============================================================================> Defines
#define DIALOG_WELCOME 1 // Dialogs
#define DIALOG_REGISTER 2
#define DIALOG_LOGIN 3
#define DIALOG_CLASS 4
#define DIALOG_TUTORIAL 5
#define PATH "/Users/%s.ini"
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"
//=============================================================================> News, enums, forwards, stocks
new Text: Title; // Texts
new PlayerText: ClassInformation[MAX_PLAYERS]; // PlayerTexts
new bool: Spawn[MAX_PLAYERS] = false; // Booleans
new CameraView[MAX_PLAYERS] = -1; // Other
enum pInfo
{
pTutorial,
pPass,
pCash,
Float:pHealth, Float:pArmour,
Float:pX, Float:pY, Float:pZ, Float:pAngle, pInterior,
pSkin
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Tutorial",PlayerInfo[playerid][pTutorial]);
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Float("Health",PlayerInfo[playerid][pHealth]);
INI_Float("Armour",PlayerInfo[playerid][pArmour]);
INI_Float("X",PlayerInfo[playerid][pX]);
INI_Float("Y",PlayerInfo[playerid][pY]);
INI_Float("Z",PlayerInfo[playerid][pZ]);
INI_Float("Angle",PlayerInfo[playerid][pAngle]);
INI_Int("Interior",PlayerInfo[playerid][pInterior]);
INI_Int("Skin",PlayerInfo[playerid][pSkin]);
return 1;
}
stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),PATH,playername);
return string;
}
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
//=============================================================================> Main()
main()
{
print("=============================");
print(" RolePlay Game Mode by Hutt2 ");
print("=============================");
}
//=============================================================================> OnGameModeInit()
public OnGameModeInit()
{
SetGameModeText("RolePlay");
SetWorldTime(0);
UsePlayerPedAnims();
AddPlayerClass(124, 1481.3420, -1748.1327, 15.4453, 0.0000, 0, 0, 0, 0, 0, 0);
AddPlayerClass(280, 1481.3420, -1748.1327, 15.4453, 0.0000, 0, 0, 0, 0, 0, 0);
Title = TextDrawCreate(320.0, 50.0, "~R~Role Play Game Mode ~n~~Y~by Hutt2");
TextDrawAlignment(Title, 2);
TextDrawFont(Title, 2);
TextDrawSetOutline(Title, 1);
TextDrawLetterSize(Title, 1, 2.5);
return 1;
}
//=============================================================================> OnPlayerRequestClass(playerid, classid)
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerFacingAngle(playerid, 0.0000);
SetPlayerPos(playerid, 1481.3420, -1748.1327, 15.4453);
SetPlayerCameraPos(playerid, 1480.6305, -1732.3672, 20.3828);
SetPlayerCameraLookAt(playerid, 1481.3420, -1748.1327, 15.4453);
PlayerTextDrawShow(playerid, ClassInformation[playerid]);
return 1;
}
//=============================================================================> OnPlayerConnect(playerid)
public OnPlayerConnect(playerid)
{
TextDrawShowForPlayer(playerid, Title);
ShowPlayerDialog(playerid, DIALOG_WELCOME, DIALOG_STYLE_MSGBOX, ""COL_WHITE"Vítej na serveru!", ""COL_WHITE"Právě se nacházíš na SA-MP serveru RolePlay od Hutta2. Pro hraní se musíš registrovat nebo přihlásit!", "Dále", "");
ClassInformation[playerid] = CreatePlayerTextDraw(playerid, 320.0, 300.0, "Klikni pro informace o charakteru!");
PlayerTextDrawAlignment(playerid, ClassInformation[playerid], 2);
PlayerTextDrawFont(playerid, ClassInformation[playerid], 2);
PlayerTextDrawLetterSize(playerid, ClassInformation[playerid], 0.5, 2);
PlayerTextDrawTextSize(playerid, ClassInformation[playerid], 20.0, 400.0);
PlayerTextDrawUseBox(playerid, ClassInformation[playerid], true);
PlayerTextDrawSetSelectable(playerid, ClassInformation[playerid], true);
return 1;
}
//=============================================================================> OnPlayerDisconnect(playerid, reason)
public OnPlayerDisconnect(playerid, reason)
{
if (fexist(UserPath(playerid)))
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Tutorial",1);
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
new Float:health, Float:armour;
GetPlayerHealth(playerid,health);
GetPlayerArmour(playerid,armour);
INI_WriteFloat(File,"Health",health);
INI_WriteFloat(File,"Armour",armour);
new Float:x, Float:y, Float:z, Float:angle;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angle);
INI_WriteFloat(File,"X",x);
INI_WriteFloat(File,"Y",y);
INI_WriteFloat(File,"Z",z);
INI_WriteFloat(File,"Angle",angle);
INI_WriteInt(File,"Interior",GetPlayerInterior(playerid));
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_Close(File);
}
return 1;
}
//=============================================================================> OnPlayerSpawn(playerid)
public OnPlayerSpawn(playerid)
{
TextDrawHideForPlayer(playerid, Title);
PlayerTextDrawDestroy(playerid, ClassInformation[playerid]);
if(fexist(UserPath(playerid)))
{
if (PlayerInfo[playerid][pTutorial] == 0)
{
TogglePlayerControllable(playerid, false);
CameraView[playerid] = 0;
CancelSelectTextDraw(playerid);
if (GetPlayerSkin(playerid) == 124)
{
GivePlayerWeapon(playerid, 22, 60);
GivePlayerMoney(playerid, 250);
}
if (GetPlayerSkin(playerid) == 280)
{
GivePlayerWeapon(playerid, 3, 1);
GivePlayerMoney(playerid, 1000);
}
}
else
{
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
SetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pAngle]);
SetPlayerInterior(playerid, PlayerInfo[playerid][pInterior]);
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
}
}
return 1;
}
//=============================================================================> OnPlayerRequestSpawn(playerid)
public OnPlayerRequestSpawn(playerid)
{
if (Spawn[playerid] == true)
{
return 1;
}
return 0;
}
//=============================================================================> OnPlayerUpdate(playerid)
public OnPlayerUpdate(playerid)
{
switch(CameraView[playerid])
{
case 0:
{
SetPlayerCameraPos(playerid, 207.8208, -85.0425, 10.4325);
SetPlayerCameraLookAt(playerid, 207.8208, -63.0425, 1.5781);
ShowPlayerDialog(playerid, DIALOG_TUTORIAL, DIALOG_STYLE_MSGBOX, "Tutoriál:", "Toto je budova úřadu.\nNa mapě je vyznačena ikonkou otazníku.\nU této budovy se dozvíš, jaké jsou na serveru povolání.", "Dál", "");
}
case 1:
{
TogglePlayerControllable(playerid, true);
SetCameraBehindPlayer(playerid);
CameraView[playerid] = -1;
}
}
}
//=============================================================================> OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_WELCOME:
{
if(fexist(UserPath(playerid)))
{
Spawn[playerid] = false;
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Přihlášení:",""COL_WHITE"Zadej své heslo pro přihlášení.","Přihlásit","Konec");
}
else
{
Spawn[playerid] = false;
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registrace:",""COL_WHITE"Zadej své heslo pro vytvoření nového účtu.","Registrovat","Konec");
}
}
case DIALOG_REGISTER:
{
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registrace",""COL_RED"Zadal jsi neplatné heslo.\n"COL_WHITE"Zadej své heslo pro vytvoření nového účtu.","Registrovat","Konec");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Tutorial",0);
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_Close(File);
ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_MSGBOX, "Tutoriál:", "Nyní si vyber začáteční povolání.\nK začátečnímu povolání dostaneš bonusové zkušenosti hned se začátku.", "Dál", "");
}
else return Kick(playerid);
}
case DIALOG_LOGIN:
{
if(response)
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
SpawnPlayer(playerid);
}
else
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Přihlášení:",""COL_RED"Zadal jsi špatné heslo.\n"COL_WHITE"Zadej své heslo pro přihlášení.","Přihlásit","Konec");
}
else return Kick(playerid);
}
case DIALOG_CLASS:
{
Spawn[playerid] = true;
SelectTextDraw(playerid, 0x00000000);
}
case DIALOG_TUTORIAL:
{
CameraView[playerid] += 1;
}
}
return 1;
}
//=============================================================================> PlayerTextDrawSetSelectable(playerid, PlayerText:text, set)
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
if (playertextid == ClassInformation[playerid])
{
if (GetPlayerSkin(playerid) == 124)
{
ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_MSGBOX, ""COL_WHITE"Výběr charakteru:", ""COL_WHITE"Mafián - Získáš 5 mafiánských zkušeností navíc. Se začátku dostaneš zbraň 9mm a 250$.\nHodnosti - U mafie můžeš dosáhnout tří hodností:\n"COL_RED"Voják\n"COL_RED"Kapitán\n"COL_RED"Šéf", "Zpět", "");
}
if (GetPlayerSkin(playerid) == 280)
{
ShowPlayerDialog(playerid, DIALOG_CLASS, DIALOG_STYLE_MSGBOX, ""COL_WHITE"Výběr charakteru:", ""COL_WHITE"Policista - Získáš 5 policeiních zkušeností navíc. Se začátku dostaneš zbraň obušek a 1000$.\nHodnosti - U policie můžeš dosáhnout tří hodností:\n"COL_RED"Policista\n"COL_RED"FBI Agent\n"COL_RED"S.W.A.T Special Forces", "Zpět", "");
}
}
return 1;
}