21.07.2010, 16:35
(
Последний раз редактировалось DJDhan; 21.07.2010 в 17:07.
)
Well if you want to use strtok, here:
I'll add the "setadminlevel" command in a minute.
EDIT:
You can be more efficient by using sscanf instead of strtok.
EDIT: I have edited the code above and should be fine. I increased the cell sizes and replaced "params" with "cmdtext".
Код:
if(!strcmp(cmdtext, "/world", true))
{
new tmp[256],wid;
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /world [worldid]");
wid = strval(tmp);
new string[128],name[64];
GetPlayerName(playerid,name,sizeof(name));
SetPlayerVirtualWorld(playerid, wid);
format(string,sizeof(string),"You have set your world to: %s.",wid);
SendClientMessage(playerid, COLOR_AFK, string);
return 1;
}
EDIT:
Код:
if(!strcmp(cmdtext,"/setadminlevel",true))
{
if(Admin[playerid] < 9) return SendClientMessage(playerid,0xffffffaa,"You do not enough admin privelege.");
new tmp[256],tmp2[256],id,level;
tmp = strtok(cmdtext,idx);
tmp2= strtok(cmdtext,idx);
if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,0xffffffaa,"Usage : /setadminlevel playerid level");
id = strval(tmp);
level=strval(tmp2);
Admin[id] = level;
return 1;
}
EDIT: I have edited the code above and should be fine. I increased the cell sizes and replaced "params" with "cmdtext".

