A few commands work on ID 0 only.
#1

As the title says , a few commands in my script work only for ID 0 .
They're alot of 'em so if you can't tell me what could be wrong , ill provide a few.

Example :
pawn Код:
CMD:get(playerid, params[])
{
new id;
if(IsPlayerConnected(id))
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
if(sscanf(params, "u", id))
{
new string[300];
new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z); SetPlayerInterior(id,GetPlayerInterior(playerid));
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "{00FFFF}*{EEEEEE}Administrator %s has teleported you to him", name);
SendClientMessage(id,COLOR_WHITE, string);
format(string, sizeof(string), "{00FFFF}*{EEEEEE}You have teleported %s to you", PlayerName);
SendClientMessage(playerid,COLOR_WHITE, string);
SetPlayerVirtualWorld(id,GetPlayerVirtualWorld(playerid));
SetPlayerPos(id,x+2,y,z);
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "{00FFFF}*{EEEEEE}Usage:gethere[Playername/ID]");
}
else return NOACCESS
}
else return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
}
If i type /goto , it will tp me to id 0 and if i type /goto 1 it will give the sscanf error message.
Reply
#2

if(IsPlayerConnected(id)) put this under the If(sscanf .... )
Reply
#3

Код:
CMD:get(playerid, params[])
{
new id;
if(PlayerInfo[playerid][pAdmin] >= 1)
{
if(sscanf(params, "i", id))
{
 SendClientMessage(playerid, COLOR_RED, "{00FFFF}*{EEEEEE}Usage:gethere[Playername/ID]");
return 1;
}
else 
{
if(IsPlayerConnected(id))
{
new string[256];
new name[MAX_PLAYER_NAME+1], PlayerName[MAX_PLAYER_NAME+1];
new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z); SetPlayerInterior(id,GetPlayerInterior(playerid));
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "{00FFFF}*{EEEEEE}Administrator %s has teleported you to him", name);
SendClientMessage(id,COLOR_WHITE, string);
format(string, sizeof(string), "{00FFFF}*{EEEEEE}You have teleported %s to you", PlayerName);
SendClientMessage(playerid,COLOR_WHITE, string);
SetPlayerVirtualWorld(id,GetPlayerVirtualWorld(playerid));
SetPlayerPos(id,x+2,y,z);
}
else
{
 SendClientMessage(playerid, COLOR_RED, "Inactive");
return 1;
}
}
}
else
{
 SendClientMessage(playerid, COLOR_RED, "You are not an Admin");
return 1;
}
return 1;
}
Reply
#4

You used sscanf in a wrong way
This is the right way
pawn Код:
if(sscanf(params,"u",id)) return SendClientMessage(playerid, color,"usage:......");
new string[300];
//Rest of the code
Reply
#5

pawn Код:
CMD:get(playerid, params[])
{
    if(!PlayerInfo[playerid][pAdmin]) return NOACCESS;
    new id;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED, "{00FFFF}*{EEEEEE}Usage: /gethere [Playername/ID]");
    if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Player is not connected.");
    new string[75], name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME], Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerInterior(id, GetPlayerInterior(playerid));
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(id, PlayerName, sizeof(PlayerName));
    format(string, sizeof(string), "{00FFFF}*{EEEEEE}Administrator %s has teleported you to him", name);
    SendClientMessage(id, COLOR_WHITE, string);
    format(string, sizeof(string), "{00FFFF}*{EEEEEE}You have teleported %s to you", PlayerName);
    SendClientMessage(playerid, COLOR_WHITE, string);
    SetPlayerVirtualWorld(id, GetPlayerVirtualWorld(playerid));
    SetPlayerPos(id, x + 2, y, z);
    return 1;
}
As mentioned above, a variable has a default value of '0' or 'false' when created, so IsPlayerConnected(id) would be IsPlayerConnected(0).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)