public OnPlayerSpawn(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
TogglePlayerControllable(playerid, true);
format(file, sizeof(file), SERVER_USER_FILE, name);
if(gPlayerLogged[playerid] == 1 && PlayerInfo[playerid][Registrado] == 1 && PlayerInfo[playerid][Jail] == 1)
{
SetPlayerPos(playerid, 264.35, 77.95, 1001.04);
SetPlayerInterior(playerid, 6);
SendClientMessage(playerid, vermelho, "The administrator hasn't unjailed you yet");
jail[playerid]=1;
dini_IntSet(file,"Spawnou",1);
PlayerInfo[playerid][Spawnou] = 1;
}
else if(PlayerInfo[playerid][Registrado] == 1 && PlayerInfo[playerid][Jail] == 0 && PlayerInfo[playerid][Spawnou] == 0)
{
new string[128]; new nome[30];
GetPlayerName(playerid, nome, 30);
format(file,sizeof(file),SERVER_USER_FILE,nome);
format(string,sizeof(string),"SERVER: %s [ID: %d] spawnou!",nome,playerid);
printf(string);
SetPlayerInterior(playerid, 0);
GangZoneShowForPlayer(playerid, gangzone[0], 0xFF9933FF);
SetPlayerPos(playerid, dini_Int(file,"PosX"),dini_Int(file,"PosY"),dini_Int(file,"PosZ")+1);
SendClientMessageToAll(0xAE5EFFFF, string);
SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]);
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid, 0);
CreateDynamicMapIcon(1338.39, 2153.30, 11.02, 58, 0, -1,-1,-1,distance);
CreateDynamicMapIcon(1933.83, 1345.05, 9.97, 30, 0, -1,-1,-1,distance);
CreateDynamicMapIcon(2019.78, 1004.03, 10.82, 44, 0, -1,-1,-1,distance);
CreateDynamicMapIcon(2201.43, 931.20, 10.82, 55, 0, -1,-1,-1,distance);
CreateDynamicMapIcon(2177.25, 962.21, 10.82, 18,0,-1,-1,-1,distance);
dini_IntSet(file,"Spawnou",1);
PlayerInfo[playerid][Spawnou] = 1;
}
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
new n[MAX_PLAYERS];GetPlayerName(playerid,n,sizeof(n));format(file,sizeof(file),SERVER_USER_FILE,n);
if(!dini_Exists(file))
{
new nome[30]; GetPlayerName(playerid, nome, 30);
ForceClassSelection(playerid);
TogglePlayerControllable(playerid, false);
ShowPlayerDialog(playerid, 7, DIALOG_STYLE_MSGBOX, "{05E35A}Attention: READ", "{05E35A}Attention. Please, use /register <password> for you be able to spawn. You can't spawn without registering\nAtenзгo. Por favor, use /register <senha> para spawnar. Vocк nгo pode spawnar sem se registrar!","Ok","Ok");
GameTextForPlayer(playerid, "~r~Register before~y~spawn~b~ please",5000,5);
PlayerPlaySound(playerid, 1138, 0.0, 0.0, 0.0);
SendClientMessage(playerid, cinza, "Use: /skin <id> para trocar seu skin!");
return 0;
}
if(dini_Exists(file) && gPlayerLogged[playerid] == 0)
{
new nome[30]; GetPlayerName(playerid, nome, 30);
GameTextForPlayer(playerid, "~r~Login before~y~spawn~b~ please",5000,5);
PlayerPlaySound(playerid, 1138, 0.0, 0.0, 0.0);
ShowPlayerDialog(playerid, 8, DIALOG_STYLE_MSGBOX, "{05E35A}Attention: READ", "{05E35A}Attention. Please, use /login <password> for you be able to spawn. You can't spawn without login\nAtenзгo. Por favor, use /login <senha> para spawnar. Vocк nгo pode spawnar sem se logar!","Ok","Ok");
return 0;
}
return 1;
}
Wanna know why? because you're checking a file on OnPlayerRequestSpawn combined with return 0;
When you hold shift, OnPlayerRequestSpawn would be called like 50x a second, and the server would be flooded for checking a file. And what does this has to do with 0.3c anyways? |
On this callback, he'll request for spawn. I'm not forcing. It's for block the player going to the next callback, which is the spawn. Just tell me how to avoid the error I told on my first post. Or if is it a bug. Else tell me how to do what DVDK said.
|
Check if the account exist on OnPlayerConnect and save it into a variable.
|