Command Problem
#1

pawn Код:
CMD:goto(playerid, params[])
{
    new Float:pX,Float:pY,Float:pZ, id;

    if(sscanf(params, "u", id)) SendClientMessage(playerid, LIGHTBLUE, "USAGE: {FFFFFF}/goto [playerid]");
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, ORANGERED, "ERROR: Invalid PlayerID");
    else
    {
        if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            GetPlayerPos(id,pX,pY,pZ);
            SetVehiclePos(GetPlayerVehicleID(playerid),pX,pY,pZ+2);
        }
        else
        {
            GetPlayerPos(id,pX,pY,pZ);
            SetPlayerPos(playerid,pX,pY,pZ+2);
        }
        SetPlayerInterior(playerid,GetPlayerInterior(id));
    }
    return 1;
}
I get no error from this code, but if i enter an invalid player id it doesent say Invalid PlayerID yet it teleports me somwhere in the map. I use zcmd and sscanf2 plugin for the command. Please help
Reply
#2

Try this
pawn Код:
CMD:goto(playerid, params[])
{
    new Float:pX,Float:pY,Float:pZ, id;

    if(sscanf(params, "u", id)) return SendClientMessage(playerid, LIGHTBLUE, "USAGE: {FFFFFF}/goto [playerid]");
    else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, ORANGERED, "ERROR: Invalid PlayerID");
    else
    {
        if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            GetPlayerPos(id,pX,pY,pZ);
            SetVehiclePos(GetPlayerVehicleID(playerid),pX,pY,pZ+2);
        }
        else
        {
            GetPlayerPos(id,pX,pY,pZ);
            SetPlayerPos(playerid,pX,pY,pZ+2);
        }
        SetPlayerInterior(playerid,GetPlayerInterior(id));
    }
    return 1;
}
Reply
#3

edited your code and came up with this:

pawn Код:
cmd:goto(playerid, params[])
{
    if(IsPlayerConnecteD(playerid))
    {
        new Float:pX, Float:pY, Float:pZ, id;
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, LIGHTBLUE, "USAGE: {FFFFFF}/goto [playerid]");
        if(id != INVALID_PLAYER_ID)
        {
            GetPlayerPos(id, pX, pY, pZ);
            new playerint = GetPlayerInterior(id);
            new playerworld = GetPlayerVirtualWorld(id);
           
            if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                SetVehiclePos(GetPlayerVehicleID(playerid), pX, pY, pZ+2);
            }
            else
            {
                SetPlayerPos(playerid, pX, pY, pZ+);
            }
           
            SetPlayerInterior(playerid, playerint);
            SetPlayerVirtualWorld(playerid, playerworld);
        }
        else SendClientMessage(playerid, ORANGERED, "ERROR: Invalid PlayerID");
    }
    return 1;
}
try it, i also added variables wherein it gets the target id's interior and virtual world.
Reply
#4

I dont know why, but for some reason this wont work, maybe somethings wrong with my script.
Reply
#5

have you tried the code that i posted?
Reply
#6

Yes i have, it still teleports me to a random location if i type an invalid id.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)