27.11.2010, 00:08
Here's my new code with sscanf.
When I do /sellgun when my job isn't Arms Dealer (job 6), it shows nothing. If I do /sellgun with no extra parameters as an arms dealer, it jump to the "Works" part of the code, when it should go to "Gun List". If I type /sellgun (targetid) (gun name), it jumps to the "Gun List" part.
I am so confused. Are there no better ways to do this? :P
Thanks!
Код:
dcmd_sellgun( playerid, params[] ) { new otherid, wepname[50]; new string[64], PlayerName[24]; new number; GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); format(string, sizeof(string),"xadmin/Users/%s.ini", udb_encode(PlayerName)); number = dini_Int(string, "Job"); if(sscanf(params, "us", otherid, wepname)) { if(number == 6) { if(otherid == INVALID_PLAYER_ID) { SendClientMessage(playerid, CHAT_COLOR_RED, "Invalid Player ID!"); } else { SendClientMessage(playerid, CHAT_COLOR_RED, "Works"); } } } else { if(number == 6) { SendClientMessage(playerid, CHAT_COLOR_RED, "Gun List"); } else if(number != 6) { SendClientMessage(playerid, CHAT_COLOR_RED, "You are not an Arms Dealer!"); } } return 1; }
I am so confused. Are there no better ways to do this? :P
Thanks!