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

Ok so I tried to make a /world (setworld) and when I do /world [worldid] it sets it to something random eg: /world 0 world gets set to world 48
Code:
pawn Код:
if(!strcmp(cmdtext, "/world", true, 3))
{
    if(!cmdtext[6])return SendClientMessage(playerid, COLOR_RED, "USAGE: /world [world]");
    new string[128];
    new name[MAX_PLAYERS];
    GetPlayerName(playerid,name,sizeof(name));
    SetPlayerVirtualWorld(playerid, cmdtext[7]);
    format(string,sizeof(string),"You have set your world to: %s.",cmdtext[7]);
    SendClientMessage(playerid, COLOR_AFK, string);
    return 1;
}
My other question I found out how to make a /slap [playerid] but I can not figure out how to make a /setadminlevel [playerid] [level]
The slap cmd
pawn Код:
if(strcmp(cmd, "/sal", true) == 0)
{
    new string[256];
    new adminname[256];
    new playername[256];
    new id;
    new tmp[256];
    new Float:health, Float:x, Float:y, Float:z;
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, COLOR_WHITE, "Usage: /slap <playerid>");
        return 1;
     }
     if(Admin[playerid] >= 10)
     {
        id = strval(tmp);
        if(IsPlayerConnected(id))
    {
            GetPlayerPos(id, x, y, z);
            PlayerPlaySound(id, 1190, x, y, z);
            SetPlayerPos(id, x, y, z+10);
                GetPlayerHealth(id, health);
                SetPlayerHealth(id, health-5);
            GetPlayerName(id, playername, 256);
            GetPlayerName(playerid, adminname, 256);
                format(string, sizeof(string), "%s has slapped %s.", adminname, playername);
                SendClientMessageToAll(COLOR_ADMIN, string);
        }
        else
    {
            format(string, sizeof(string), "%d is not an active player.", id);
            SendClientMessage(playerid, COLOR_RED, string);
        }
      }
      else
      {
            SendClientMessage(playerid,COLOR_RED,"ERROR: You are not the correct level admin.");
       }
       return 1;
}
Any help/thoughts?
Reply
#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
#3

The Setadmin command above will only work for people under level 9...
Reply
#4

pawn Код:
C:\Servers\SA-MP\gamemodes\MS.pwn(1476) : error 017: undefined symbol "params"
C:\Servers\SA-MP\gamemodes\MS.pwn(1476) : error 047: array sizes do not match, or destination array is too small
C:\Servers\SA-MP\gamemodes\MS.pwn(1949) : error 047: array sizes do not match, or destination array is too small
C:\Servers\SA-MP\gamemodes\MS.pwn(1950) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)