CMD:defend(playerid, params[]) { static userid, price; if (PlayerData[playerid][pJob] != JOB_LAWYER) return SendErrorMessage(playerid, "You cant use that command."); if (!IsPlayerNearPlayer(playerid, userid, 6.0)) return SendErrorMessage(playerid, "Player is not below you."); if (userid == INVALID_PLAYER_ID) return SendErrorMessage(playerid, "Player is offline."); if (userid == playerid) return SendErrorMessage(playerid, "You cant defend yourself."); new string[128]; if(PlayerData[playerid][pLawyerTime] >= 1) { format(string, sizeof(string), "You must wait %d seconds!", PlayerData[playerid][pLawyerTime]); SendClientMessage(playerid, COLOR_GREY,string); return 1; } if (sscanf(string, "ud", userid, price)) return SendSyntaxMessage(playerid, "/defend [Name_Lastname/ID] [price]"); if (PlayerData[userid][pWanted] == 0) return SendErrorMessage(playerid, "Player dont have warrants!"); new playermoney = PlayerData[playerid][pMoney]; if(price > 0 && playermoney >= price) { format(string, sizeof(string), "* You offered to %s to defend him for $%d.", ReturnName(userid, 0), price); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); format(string, sizeof(string), "* Lawyer %s offered you to defend u for $%d, (usage /accept defend) to accept.", ReturnName(playerid, 0), price); SendClientMessage(userid, COLOR_LIGHTBLUE, string); PlayerData[playerid][pLawyerTime] = 60; DefendOffer[userid] = playerid; DefendPrice[userid] = price; } return 1; }
CMD:defend(playerid, params[])
{
new userid, price, string[128];
new playermoney = PlayerData[playerid][pMoney];
if(sscanf(params, "ud", userid, price)) return SendSyntaxMessage(playerid, "/defend [Name/ID] [price]");
if(PlayerData[playerid][pJob] != JOB_LAWYER) return SendErrorMessage(playerid, "You cant use that command.");
if(!IsPlayerConnected(userid)) return SendErrorMessage(playerid, "Player is offline.");
if(!IsPlayerNearPlayer(playerid, userid, 6.0)) return SendErrorMessage(playerid, "Player is not below you.");
if(userid == playerid) return SendErrorMessage(playerid, "You cant defend yourself.");
if(PlayerData[userid][pWanted] == 0) return SendErrorMessage(playerid, "Player dont have warrants!");
if(PlayerData[playerid][pLawyerTime] >= 1)
{
format(string, sizeof(string), "You must wait %d seconds!", PlayerData[playerid][pLawyerTime]);
SendClientMessage(playerid, COLOR_GREY,string);
return 1;
}
if(price > 0 && playermoney >= price)
{
format(string, sizeof(string), "* You offered to %s to defend him for $%d.", ReturnName(userid, 0), price);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "* Lawyer %s offered you to defend u for $%d, (usage /accept defend) to accept.", ReturnName(playerid, 0), price);
SendClientMessage(userid, COLOR_LIGHTBLUE, string);
PlayerData[playerid][pLawyerTime] = 60;
DefendOffer[userid] = playerid;
DefendPrice[userid] = price;
}
return 1;
}
You changed " ud " into " dd " ..
And he didn't gave the player anything.. so ofc the cmd goes waste, Let him say what he wants to give the player.. and how much.. Good day |
// change:
if (sscanf(string, "ud", userid, price))
return SendSyntaxMessage(playerid, "/defend [Name_Lastname/ID] [price]");
// to:
if (sscanf(params, "ud", userid, price))
return SendSyntaxMessage(playerid, "/defend [Name_Lastname/ID] [price]");
He used "u" specifier and that's correct if he wants to use the name too instead of only the player's ID.
The problem is that you used sscanf on "string" which is actually empty instead of "params": PHP код:
|