/world does not work correctly | and trouble with making /setadminlevel
#2

Well if you want to use strtok, here:
Код:
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;
}
I'll add the "setadminlevel" command in a minute.


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;
}
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".
Reply


Messages In This Thread
/world does not work correctly | and trouble with making /setadminlevel - by Яσскѕтая - 21.07.2010, 16:08
Re: /world does not work correctly | and trouble with making /setadminlevel - by DJDhan - 21.07.2010, 16:35
Re: /world does not work correctly | and trouble with making /setadminlevel - by John_F - 21.07.2010, 16:54
Re: /world does not work correctly | and trouble with making /setadminlevel - by Яσскѕтая - 21.07.2010, 17:03

Forum Jump:


Users browsing this thread: 3 Guest(s)