CMD:set(playerid,params[]) { new str[128], option[30], targetid, level; if(sscanf(params, "s[30]", option)) { SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: /set [option]"); return SendClientMessage(playerid, 0xFFFFFFFF, "Available options: adminlevel"); } if(strmatch(params, "adminlevel")) { if(sscanf(params, "s[30]ui", option, targetid, level)) format(str,sizeof(str),"You gave %s(%i) admin level %i!",GetName(targetid), targetid, level); SendClientMessage(playerid,-1,str); PlayerInfo[targetid][pAdmin] = level; } else return cmd_set(playerid, ""); return 1; }
if(sscanf(params, "s[30]", option)) {
if(sscanf(params, "s[30]ui", option, targetid, level))
if(sscanf(params, "rs[30]i", option, targetid, level)) {
CMD:set(playerid,params[]) { new string[128], giveplayerid, statcode, level; if(sscanf(params, "udd", giveplayerid, statcode, level)) { SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: /set [option]"); return SendClientMessage(playerid, 0xFFFFFFFF, "Available options: adminlevel"); } if(IsPlayerConnected(giveplayerid)) { switch (statcode) { case 1: { format(string,sizeof(string),"You gave %s(%i) admin level %i!",GetName(giveplayerid), giveplayerid, level); SendClientMessage(playerid,-1, string); PlayerInfo[giveplayerid][pAdmin] = level; } } return 1; }
if(sscanf(params, "s[30]ui", option, targetid, level))
format(str,sizeof(str),"You gave %s(%i) admin level %i!",GetName(targetid), targetid, level);
SendClientMessage(playerid,-1,str);
PlayerInfo[targetid][pAdmin] = level;
if(sscanf(params, "s[30]ui", option, targetid, level))
{
format(str,sizeof(str),"You gave %s(%i) admin level %i!",GetName(targetid), targetid, level);
}
SendClientMessage(playerid,-1,str);
PlayerInfo[targetid][pAdmin] = level;
if(sscanf(params, "s[30]ui", option, targetid, level))
{
return SendClientMessage(playerid,-1, "/set adminlevel [ID] [Level]");
}
format(str,sizeof(str),"You gave %s(%i) admin level %i!",GetName(targetid), targetid, level);
SendClientMessage(playerid,-1,str);
PlayerInfo[targetid][pAdmin] = level;
PHP код:
PHP код:
You didn't provide anything for the sscanf to do if there aren't enough params there. What happens now is that it always sends you an empty message (str variable) because the format function is only called when sscanf doesn't pass correctly. PHP код:
If it doesn't, please be more specific, can you print out the params before sscanf, then print out the scanned variables after using sscanf or something more? It would help knowing some more info on what to look for. Also, it might be problematic that you only scan for a string at the start. This is pure speculation, as I don't correctly remember if this is how it works but if you write "/set adminlevel user 1" could possibly make option = "adminlevel user 1" and then strmatch will not pass. Although, I don't know how strmatch works as I use strcmp for these cases. If you don't want to change your code to accommodate strcmp, you can try using strfind, don't forget to look it up in the wiki to see how it works beforehand. This would probably fix the problem. Or you can modify the first sscanf and only scan to the first space, which would probably work, I suppose. |
CMD:set(playerid,params[]) { new str[128], option[30], targetid, level; if(sscanf(params, "s[30]", option)) { SendClientMessage(playerid, 0xFFFFFFFF, "SERVER: /set [option]"); return SendClientMessage(playerid, 0xFFFFFFFF, "Available options: adminlevel"); } if(strmatch(option, "adminlevel")) { if(sscanf(params, "s[30]ui", option, targetid, level)) { return SendClientMessage(playerid,-1, "/set adminlevel [ID] [Level]"); } format(str,sizeof(str),"You gave %s(%i) admin level %i!",GetName(targetid), targetid, level); SendClientMessage(playerid,-1,str); PlayerInfo[targetid][pAdmin] = level; } else return cmd_set(playerid, ""); return 1; }
I got it working thanks to Dayrion's post on this thread: http://forum.sa-mp.com/showthread.ph...85#post3980785
Thanks a lot for everyone who tried to help! |