/get command works only for ID 0
#1

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;
}
Reply
#2

Update sscanf.
Reply
#3

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

OnTopic:

Dude update your strtok/whatever to sscanf
Reply
#4

How i can update it?
Reply
#5

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

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

OnTopic:

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

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;
}
Reply
#8

Comment deleted by user!
Reply
#9

blewert,

i have errors with your code.

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)