[maybe an bug] OnPlayerClassRequest
#1

I use dini for saving / loading positions, money, score, skin, name, ip and some other things. The issue is on the class selection, that if you press shift instead the button spawn, this spawns without loading position / skin, goes to the certain class info. Example: I chose the firefighter. The class 1. There will load the position I put on AddStaticClass (wepaons + position), instead the player's position/skin on dini file. This is not a problem on my system, since it doesn't happens ever.

My code, always:
pawn Код:
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;
}
pawn Код:
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;
}
Reply
#2

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?
Reply
#3

Quote:
Originally Posted by DVDK
Посмотреть сообщение
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?
Hm, sorry. I thought it might be a bug, since I never had it on other versions dude =x. How do I resolve so? put return ShowPlayerDialog... ? Or remove the return?
Reply
#4

why are you doing ForceClassSelection(playerid);?

if you return 0 u'll still be in class selection.
Reply
#5

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.
Reply
#6

Quote:
Originally Posted by blackwave
Посмотреть сообщение
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.
Reply
#7

Quote:
Originally Posted by DVDK
Посмотреть сообщение
Check if the account exist on OnPlayerConnect and save it into a variable.
I am not checking if it does exists or no. It's checking if the player is logged or registered. And I put on request spawn instead of spawnplayer, cuz I had to kill the player.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)