SA-MP Forums Archive
/get command works only for 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: /get command works only for ID 0 (/showthread.php?tid=332445)



/get command works only for ID 0 - SkyWings - 08.04.2012

Hi guys,

do someone can fix this code? This is a /get command, and this code works only for ID 0.

Код:
	CMD:get(playerid, params[]){
		if(Donator[playerid])
	{
	new tmp[256];
	tmp = "";
		if(!IsPlayerConnected(strval(tmp))) {
			SendClientMessage(playerid, RAUDONA,"This player dosn't exists.");
		} else {
			new Float:X;
			new Float:Y;
			new Float:Z;
			new Float:Angle;
			if(IsPlayerInAnyVehicle(strval(tmp))) {
			    new VehicleID;
				VehicleID = GetPlayerVehicleID(strval(tmp));
				GetPlayerPos(playerid,X,Y,Z);
				SetVehiclePos(VehicleID, X + 0.01, Y + 0.01, Z);
                GetPlayerFacingAngle(playerid,Angle);
				SetPlayerFacingAngle(strval(tmp),Angle);
			} else {
				GetPlayerPos(playerid,X,Y,Z);
                GetPlayerFacingAngle(playerid,Angle);
				SetPlayerFacingAngle(strval(tmp),Angle);
				SetPlayerPos(strval(tmp), X + 0.01, Y + 0.01, Z);
			}
			SendClientMessage(playerid, BALTA,"Player has been teleported to you.");
	}
	     } else {
		SendClientMessage(playerid, MELYNA, "This command can use only administrator.");
		}
	return 1;
}



Re: /get command works only for ID 0 - Jack.7331 - 08.04.2012

Update sscanf.


Re: /get command works only for ID 0 - Reklez - 08.04.2012

Quote:
Originally Posted by Jack.7331
Посмотреть сообщение
Update sscanf.
Update sscanf? he is using strtok or whatever

OnTopic:

Dude update your strtok/whatever to sscanf


Re: /get command works only for ID 0 - SkyWings - 08.04.2012

How i can update it?


Re: /get command works only for ID 0 - Reklez - 08.04.2012

Download it from here!

then put ssscanf2.inc in your pawno/include
then put sscanf.dll in your plugins/

now put this at the of script

pawn Код:
#include <sscanf2>



Re: /get command works only for ID 0 - Jack.7331 - 08.04.2012

Quote:
Originally Posted by Reklez
Посмотреть сообщение
Update sscanf? he is using strtok

OnTopic:

Dude update your strtok to sscanf
I meant update to.. /me facepalms.


Re: /get command works only for ID 0 - blewert - 08.04.2012

Quote:
Originally Posted by SkyWings
Посмотреть сообщение
Код:
	new tmp[256];
	tmp = "";
This is why. You're creating a variable called tmp, assigning null to it, converting it to a value and then referencing it: which will always be 0.

params are there for command parameters, so you should be checking the value of this, not some variable you just created.

pawn Код:
CMD:get(playerid, params[])
{
    if(Donator[playerid])
    {

        if(!IsPlayerConnected(strval(params)))
        {
            SendClientMessage(playerid, RAUDONA,"This player dosn't exists.");
        }
        else
        {
            new Float:X;
            new Float:Y;
            new Float:Z;
            new Float:Angle;
            if(IsPlayerInAnyVehicle(strval(params)))
            {
                new VehicleID;
                VehicleID = GetPlayerVehicleID(strval(params));
                GetPlayerPos(playerid,X,Y,Z);
                SetVehiclePos(VehicleID, X + 0.01, Y + 0.01, Z);
                GetPlayerFacingAngle(playerid,Angle);
                SetPlayerFacingAngle(strval(params),Angle);
            }
            else
            {
                GetPlayerPos(playerid,X,Y,Z);
                GetPlayerFacingAngle(playerid,Angle);
                SetPlayerFacingAngle(strval(params),Angle);
                SetPlayerPos(strval(params), X + 0.01, Y + 0.01, Z);
            }
            SendClientMessage(playerid, BALTA,"Player has been teleported to you.");
        }
    }
    else
    {
        SendClientMessage(playerid, MELYNA, "This command can use only administrator.");
    }
    return 1;
}



Re: /get command works only for ID 0 - Cjgogo - 08.04.2012

Comment deleted by user!


Re: /get command works only for ID 0 - SkyWings - 08.04.2012

blewert,

i have errors with your code.

C:\Users\SkyWings\Desktop\SERVER\filterscripts\reg ister.pwn(953) : error 001: expected token: ")", but found "{"


Re: /get command works only for ID 0 - Cjgogo - 08.04.2012

pawn Код:
CMD:get(playerid, params[])
{
    if(Donator[playerid])
    {

        if(!IsPlayerConnected(strval(params)))
        {
            SendClientMessage(playerid, RAUDONA,"This player dosn't exists.");
        }
        else
        {
            new Float:X;
            new Float:Y;
            new Float:Z;
            new Float:Angle;
            if(IsPlayerInAnyVehicle(strval(params)))
            {
                new VehicleID;
                VehicleID = GetPlayerVehicleID(strval(params));
                GetPlayerPos(playerid,X,Y,Z);
                SetVehiclePos(VehicleID, X + 0.01, Y + 0.01, Z);
                GetPlayerFacingAngle(playerid,Angle);
                SetPlayerFacingAngle(strval(params),Angle);
            }
            else
            {
                GetPlayerPos(playerid,X,Y,Z);
                GetPlayerFacingAngle(playerid,Angle);
                SetPlayerFacingAngle(strval(params),Angle);
                SetPlayerPos(strval(params), X + 0.01, Y + 0.01, Z);
            }
            SendClientMessage(playerid, BALTA,"Player has been teleported to you.");
        }
    }
    else
    {
        SendClientMessage(playerid, MELYNA, "This command can use only administrator.");
    }
    return 1;
}
Try it now and learn to fix easy errors please