SA-MP Forums Archive
[Help]Double calling the callback - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help]Double calling the callback (/showthread.php?tid=577931)



[Help]Double calling the callback - RolePlayNews - 15.06.2015

Hi, there's my problem

The OnPlayerSpawn callback is twice calling. Why?
But once calling the SpawnPlayer .

Код:
LoginForm_Logged[playerid] = 1;
        
	    mysql_format(kapcs, queryQ, 200, "UPDATE character SET ply_Status='1' WHERE ply_Order='%s'",
	 	_LoginForm_User[playerid]);
	    mysql_tquery(kapcs, queryQ, "CheckLogin","is",playerid,_LoginForm_User[playerid]);
/////////
fuggveny CheckLogin(playerid,s[])
{
if(IsLogged(playerid))
    {
	    _LoginForm(playerid);
	    CancelSelectTextDraw(playerid);


        new str2[128];
		format(str2,sizeof(str2),"SERVER: {ffffff}Welcome %s!",PlayerID[ply_Name]);
		msg(playerid,str2);

    	SpawnPlayer(playerid);
    }
}
////////////////
public OnPlayerSpawn(playerid)
{
    if(IsLogged(playerid))
	{
		if(!IsRPName(PlayerID[ply_Name]))
		{
		    SendClientMessage(playerid,SERVER_COL,"message...");
			wait(100);
			Kick(playerid);
		}
	    TogglePlayerSpectating(playerid,0);
		//
		if(PlayerID[ply_First] == 0)
		{
			SetPlayerPos(playerid,PlayerID[ply_LastPosX],PlayerID[ply_LastPosY],PlayerID[ply_LastPosZ]);
			SetPlayerFacingAngle(playerid,PlayerID[ply_LastPosA]);
			SetPlayerSkin(playerid,PlayerID[ply_Clothes]);
			SetPlayerHealth(playerid,PlayerID[ply_HitPoints]);
			SetPlayerArmour(playerid,PlayerID[ply_ArmorPoints]);
			SendClientMessage(playerid,-1,"5");
		}
		else
		{
			if(!PlayerID[ply_Name])
				ShowPlayerDialog(playerid,DIA_NAME,DIALOG_STYLE_INPUT,"Charactername"," ","Next","");

		    PlayerID[ply_SpawnPosX] = 1480.9480;
		    PlayerID[ply_SpawnPosY] = -1702.1752;
		    PlayerID[ply_SpawnPosZ] = 14.0469;
		    PlayerID[ply_SpawnPosA] = 179.0729;
		    SetPlayerPos(playerid,1480.9480,-1702.1752,14.0469);
		    SetPlayerFacingAngle(playerid,179.0729);

	  		PlayerID[ply_HitPoints] = 100.0;
	  		PlayerID[ply_ArmorPoints] = 1.0;
	  		PlayerID[ply_EnergyPoints] = 80.0;
	  		
	  		SetPlayerHealth(playerid,PlayerID[ply_HitPoints]);
			SetPlayerArmour(playerid,PlayerID[ply_ArmorPoints]);
	  		
	  		PlayerID[ply_First] = 0;
		}
		//
	}
	return 1;
}
I want to hear all the options.

Thanks in advance.


Re: [Help]Double calling the callback - Banana_Ghost - 15.06.2015

Under OnPlayerSpawn

remove TogglePlayerSpectating(playerid,0);

When 0 is passed, it turns off spectating, and calls OnPlayerSpawn.