Need help with CMD..
#5

PHP код:
if(strcmp(cmd,"/streetrespect",true) == 0)
{
       if(
gPlayerLogged[playerid] == 0) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
       if(
PlayerInfo[playerid][pCMDT] > 0) return SendClientMessage(playerid,0xFF0000FF,"Please wait before using this command again.");
       new 
idtargetname[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
       
GetPlayerName(playeridsendernamesizeof(sendername));
       if(
sscanf(cmd"u"id)) return SendClientMessage(playerid0xCC0000AA"USAGE: /streetrespect <playerid/partofname>");
       if(! 
IsPlayerConnected(id)) return SendClientMessage(playerid, -1"ID not connected");
       if(
playerid == id) return SendClientMessage(playerid, -1"You can't give Street Respect to yourself.");
       if(! 
IsPlayerInRangeOfPlayer(playeridid5.0)) return SendClientMessage(playerid, -1"You aren't close enough to the player.");
       
GetPlayerName(idtargetnamesizeof targetname);
       new 
string[128];
       
PlayerInfo[playerid][StreetRespect]++;
       
PlayerInfo[playerid][pCMDT] = 3600// example 3600 - 1 hour
       
format(stringsizeof(string), "You have gived Street Respect to %s."targetname);
       
SendClientMessage(playeridCOLOR_WHITEstring);
       
format(stringsizeof(string), "Player %s has gived you Street Respect to you."sendername);
       
SendClientMessage(idCOLOR_WHITEstring);
       return 
1;

Here, read it carefuly. You dont require ReturnUser when using sscanf. Moreover you can use that sort of indentation for cleaner code.
Errors may occur if you are already having those variables defined in the callback. So rename them or simply use the pre defined ones.

I will recommend you to use ZCMD, cause its faster, less chances of error and much more.
Reply


Messages In This Thread
Need help with CMD.. - by Scrillex - 24.02.2015, 08:45
Re: Need help with CMD.. - by Golf - 24.02.2015, 08:51
Re: Need help with CMD.. - by Scrillex - 24.02.2015, 09:23
Re: Need help with CMD.. - by Golf - 24.02.2015, 09:59
Re: Need help with CMD.. - by Gammix - 24.02.2015, 10:32
Re: Need help with CMD.. - by Golf - 24.02.2015, 10:38
Re: Need help with CMD.. - by Gammix - 24.02.2015, 12:17

Forum Jump:


Users browsing this thread: 2 Guest(s)