SA-MP Forums Archive
Help setlevel - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help setlevel (/showthread.php?tid=434578)



Help setlevel - kalanerik99 - 03.05.2013

Hi

Can someone fix that if I dont insert ID and level it will send me message "USAGE: /setlevel <ID> <Level>"

PHP код:
CMD:setlevel(playerid,params[])
{
new 
level,id,file[256],n[MAX_PLAYER_NAME];
new 
tmp[256], tmp2[256], Index,str[50];
tmp strtok(params,Index), tmp2 strtok(params,Index),id strval(tmp),level strval(tmp2);
GetPlayerName(id,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");
if(!
strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");
if(!
IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID");
if(
level || level 5) return SendClientMessage(playeridORANGE"Level must be between 0 and 5!");
PInfo[id][Level] = level;
dini_IntSet(file,"Level",level);
format(str,sizeof(str),"You have set %s's level to %d",n,level);
SendClientMessage(playerid,LIGHTBLUE,str);
return 
1;




Re: Help setlevel - zombieking - 03.05.2013

Ever thought of using sscanf?


Re : Help setlevel - Rayan_black - 03.05.2013

pawn Код:
CMD:setlevel(playerid,params[])
{
if(sscanf(params, "ui", target, level)) return SendClientMessage(playerid, red, "Correct usage: /setadmin [playerid/name] [level]");
new level,id,file[256],n[MAX_PLAYER_NAME];
new tmp[256], tmp2[256], Index,str[50];
tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);
GetPlayerName(id,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");
if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID");
if(level < 0 || level > 5) return SendClientMessage(playerid, ORANGE, "Level must be between 0 and 5!");
PInfo[id][Level] = level;
dini_IntSet(file,"Level",level);
format(str,sizeof(str),"You have set %s's level to %d",n,level);
SendClientMessage(playerid,LIGHTBLUE,str);
return 1;
}
This should solve your problem, don't forget to get sscanf inculde and include it in your gamemode/script.


Re: Help setlevel - kalanerik99 - 03.05.2013

PHP код:
error 017undefined symbol "target" 



Re : Re: Help setlevel - Rayan_black - 03.05.2013

Quote:
Originally Posted by kalanerik99
Посмотреть сообщение
PHP код:
error 017undefined symbol "target" 
hmm, it should work fine... try playerid instead of target.


Re: Help setlevel - kalanerik99 - 03.05.2013

but it show me error


Re: Help setlevel - Isolated - 03.05.2013

under CMDetlevel, create a new variable, "new target;"


Re : Re: Help setlevel - Rayan_black - 03.05.2013

Quote:
Originally Posted by kalanerik99
Посмотреть сообщение
PHP код:
error 017undefined symbol "target" 
Quote:
Originally Posted by kalanerik99
Посмотреть сообщение
but it show me error
ow yeah, sorry my bad
pawn Код:
CMD:setlevel(playerid,params[])
{
new target;
if(sscanf(params, "ui", target, level)) return SendClientMessage(playerid, red, "Correct usage: /setadmin [playerid/name] [level]");
new level,id,file[256],n[MAX_PLAYER_NAME];
new tmp[256], tmp2[256], Index,str[50];
tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);
GetPlayerName(id,n,MAX_PLAYER_NAME);
format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");
if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID");
if(level < 0 || level > 5) return SendClientMessage(playerid, ORANGE, "Level must be between 0 and 5!");
PInfo[id][Level] = level;
dini_IntSet(file,"Level",level);
format(str,sizeof(str),"You have set %s's level to %d",n,level);
SendClientMessage(playerid,LIGHTBLUE,str);
return 1;
}
now this will work ._. it's night time here, I'm so tired didn't notice my fault


Re: Help setlevel - Isolated - 03.05.2013

Or you could just have used "id".

EDIT: the whole command won't work. You'll need to either use "target" on everything or "id" on everything.


Re : Re: Help setlevel - Rayan_black - 03.05.2013

Quote:
Originally Posted by Isolated
Посмотреть сообщение
Or you could just have used "id".

EDIT: the whole command won't work. You'll need to either use "target" on everything or "id" on everything.
It compiles fine for me, meh people use codes which they didn't even make... if you don't want to get stuck with something, use your own codes.