SA-MP Forums Archive
Works only with id 0. - 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: Works only with id 0. (/showthread.php?tid=592866)



Works only with id 0. - SpikeSpigel - 30.10.2015

Hi there ! My /goto command works only for id 0, so you can teleport only to the person with id 0 .


Re: Works only with id 0. - iFiras - 30.10.2015

Show us the command.


Re: Works only with id 0. - ATGOggy - 30.10.2015

And your code?


Re: Works only with id 0. - SpikeSpigel - 30.10.2015

Fuck, I forgot to put it .
Код:
CMD:goto(playerid, params[])
{
	if(IsPlayerConnected(playerid))
	{
	    new toplayerid, Float:pos[3];

		GetPlayerPos(toplayerid, pos[0], pos[1], pos[2]);
 		
 		if (toplayerid != INVALID_PLAYER_ID)
 		{
   			if(!sscanf(params, "i", toplayerid))
			{
	    	    SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
			} else SendClientMessage(playerid, color_grey, "UTILIZARE:/goto <id>");
		}
	} else SendClientMessage(playerid, color_grey, "Acest jucator nu este connectat");
	return 1;
}



Re: Works only with id 0. - J0sh... - 30.10.2015

Your code is wrong.

PHP код:
CMD:goto(playeridparams[]) {
    new 
toplayeridFloat:pos[3];
    if(
sscanf(params"u"toplayerid)) return SendClientMessage(playeridcolor_grey"UTILIZARE:/goto <id>"); //You can do /goto <name or ID> now.
    
if(!IsPlayerConnected(toplayerid)) return SendClientMessage(playeridcolor_grey"Acest jucator nu este connectat");
    
GetPlayerPos(toplayeridpos[0], pos[1], pos[2]);
    
SetPlayerPos(playeridpos[0], pos[1], pos[2]);
    return 
1;




Re: Works only with id 0. - Macluawn - 30.10.2015

If it compiles then it`s not wrong.. Just doing what isn`t expected of it.

Analyze the flow of logic. On line 7, you're always reading the position of player 0, because toplayerid will always be 0 at that point, since it was declared just a line above - the actual is written to it only later.