SA-MP Forums Archive
Problem in ID 2 - 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: Problem in ID 2 (/showthread.php?tid=423405)



Problem in ID 2 - nor15 - 17.03.2013

when i use any command on ID 2 it says ID (3) isn't online i dunno why
here is a command
PHP код:
dcmd_rob(playerid,params[])
{
    new 
string[128];
    new 
ID;
    if(
sscanf(params"u"ID))
    {
        
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /rob (Player Name/ID)");
        return 
1;
    }
    if(
IsSpawned[playerid] != 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 
1;
    }
    if(
IsFrozen[playerid] == 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You have been frozen by a Server Administrator. You cannot use this command.");
        return 
1;
    }
    if(
InAdminMode[ID] == 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command on this player because they are in Administrator mode.");
        return 
1;
    }
    if(
IsKidnapped[playerid] == 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You are kidnapped. You cannot use this command.");
        return 
1;
    }
    if(
Away[playerid] == 1)
    {
        
SendClientMessage(playeridCOLOR_ERROR,"You can't rob someone while you are in AFK.");
        return 
1;
    }
    if(
Away[ID] == 1)
    {
        
SendClientMessage(playeridCOLOR_ERROR,"You can't rob someone while he is in AFK.");
        return 
1;
    }
    if(!
IsPlayerConnected(ID))
    {
        
format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot rob them",ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
GetDistanceBetweenPlayers(playerid,ID) > 4)
    {
        
format(string,sizeof(string),"%s(%d) is too far away. You cannot reach him to rob him.",PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot rob someone while in a vehicle. Exit the vehicle first.");
        return 
1;
    }
    if(
GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot rob someone while they are in a vehicle. Get them to exit the vehicle first.");
        return 
1;
    }
    if(
playerid == ID)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot rob yourself, how can you even manage that?");
        return 
1;
    }
    if(
IsSpawned[ID] != 1)
    {
        
format(string,sizeof(string),"%s(%d) is not spawned. You cannot rob dead people ..",PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
IsFrozen[ID] == 1)
    {
        
format(string,sizeof(string),"%s(%d) is frozen by a Server Administrator. You cannot rob them.",PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
IsCuffed[playerid] == 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot rob someone while you are cuffed, how can you manage it ?");
        return 
1;
    }
    if(
IsCuffed[ID] == 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot rob someone while he is cuffed");
        return 
1;
    }
    if(
HasRobbedRecently[playerid] >= 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You are too tired from the last person you robbed. Please wait before robbing again.");
        return 
1;
    }
    if(
HasSecureWallet[ID] != 0)
    {
        
SendClientMessage(playerid,COLOR_RED,"This player got wallet that saved him from robbery");
        
format(string,sizeof(string),"%s(%d) tried to rob you but your wallet saved you.",PlayerName(playerid),playerid);
        
SendClientMessage(ID,COLOR_DODGERBLUE,string);
        
HasSecureWallet[ID] --;
        return 
1;
    }
    if(
GetPlayerMoney(ID) <= 0)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"That player has no money in their pockets. What would be the point in robbing them?");
        return 
1;
    }
    if(
InDuel[playerid] == 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You are in a Duel you can't use this command.");
        return 
1;
    }
    if(
GetDistanceBetweenPlayers(playerid,ID) <= 4)
    {
        new 
current_zone player_zone[playerid];
        new 
mrand =random(GetPlayerMoney(ID));
        
SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Player Robbed_]]");
        
format(string,sizeof(string),"You have robbed $%d from %s(%d). Careful they dont come after you!",mrand,PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_RED,string);
        
GivePlayerMoney(playerid,mrand);
        
IncreaseWantedLevel(playerid,8);
        
HasRobbedRecently[playerid] =180;
        
IncreasePlayerScore(playerid,3);
        
        
SendClientMessage(ID,COLOR_DEADCONNECT,"[[_Robbed_]]");
        
format(string,sizeof(string),"You have had $%d robbed from you by %s(%d). Kill them for your money back or run!",mrand,PlayerName(playerid),playerid);
        
SendClientMessage(ID,COLOR_RED,string);
        
GivePlayerMoney(ID,-mrand);
        
        
format(string,sizeof(string),"[POLICE RADIO] Robbery: %s(%d) has robbed $%d from %s(%d). Location: %s.",PlayerName(playerid),playerid,mrand,PlayerName(ID),ID,zones[current_zone][zone_name]);
        
SendClientMessageToAllCops(string);
        
        
format(string,sizeof(string),"%s(%d) has robbed $%d from %s(%d).",PlayerName(playerid),playerid,mrand,PlayerName(ID),ID);
        
SendClientMessageToAll(COLOR_RED,string);
        return 
1;
    }
    return 
1;




Re: Problem in ID 2 - Jstylezzz - 17.03.2013

Is your sscanf up to date?


Re: Problem in ID 2 - nor15 - 17.03.2013

i dunno but if you got a link so give it to me


Re: Problem in ID 2 - kamzaf - 17.03.2013

instead of using !isplayerconnected, use if(ID == INVALID_PLAYER_ID) { sendclientmessage...blahblah, return 1; }

also heres the link: https://sampforum.blast.hk/showthread.php?tid=120356


Re: Problem in ID 2 - nor15 - 17.03.2013

Quote:
Originally Posted by kamzaf
Посмотреть сообщение
instead of using !isplayerconnected, use if(ID == INVALID_PLAYER_ID) { sendclientmessage...blahblah, return 1; }

also heres the link: https://sampforum.blast.hk/showthread.php?tid=120356
Thanks but can you give me a direct link ?


Re: Problem in ID 2 - N0FeaR - 17.03.2013

Try to update your sscanf


Re: Problem in ID 2 - nor15 - 17.03.2013

Quote:
Originally Posted by N0FeaR
Посмотреть сообщение
Try to update your sscanf
Read what i said i wanna a Direct link for sscanf


Re: Problem in ID 2 - kamzaf - 17.03.2013

Quote:
Originally Posted by nor15
Посмотреть сообщение
Read what i said i wanna a Direct link for sscanf
http://dl.dropbox.com/u/21683085/sscanf.rar


Re: Problem in ID 2 - nor15 - 17.03.2013

It works nice but when i write an ID that isn't connected it says [ SERVER:UNKNOWN COMMAND ]

Code :
PHP код:
if(ID == INVALID_PLAYER_ID)
    {
        
format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot rob them",ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    } 



Re: Problem in ID 2 - nor15 - 17.03.2013

Can anyone help me ? , I need an answer quickly please