SetLevel command problem[Help +repp]
#1

hey boys i am having a problem with my new command
/setlevel this its created with Dini but i get an error that i dont know
what to do to fix it cuase it is already in use
here its the problem
Код:
C:\Users\ardit_000\Desktop\BISHAT\gamemodes\test.pwn(438) : warning 203: symbol is never used: "dcmd_setlevel"
here is the command

PHP код:
dcmd_setlevel(playerid,params[])
{
    new 
level,id,file[256],n[MAX_PLAYER_NAME];//creating the new variabls
    
new tmp[256], tmp2[256], Index,str[50];// creating the new variables
    
tmp strtok(params,Index), tmp2 strtok(params,Index),id strval(tmp),level strval(tmp2);// setting them to strtok so we can use them as parameters of our command
    
GetPlayerName(id,n,MAX_PLAYER_NAME);//getting the players name
    
format(file,sizeof(file),"Admin%s.txt",n);//formatting the file
    
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");//if the player is not rcon admin
    
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");// if the string is empty
    
if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID"); //if the id is not connected
    
PInfo[id][Level] = level;//sets the level of the player
    
dini_IntSet(file,"Level",level);//saves the new level to the file
    
format(str,sizeof(str),"You have set %s's level to %d",n,level);//creates the string
    
SendClientMessage(playerid,LIGHTBLUE,str);
    return 
1;

Reply
#2

you need to put
pawn Код:
dcmd(setlevel, 8, cmdtext);
under OnPlayerCommandText
Reply
#3

i fixed it but when i login game and press that cmd it tells me that i only gave to my self admin 1 c
can you help me to make levels from 1-6 or 7


PHP код:
COMMAND:setlevel(playerid,params[])
{
    new 
level,id,file[256],n[MAX_PLAYER_NAME];//creating the new variabls
    
new tmp[256], tmp2[256], Index,str[50];// creating the new variables
    
tmp strtok(params,Index), tmp2 strtok(params,Index),id strval(tmp),level strval(tmp2);// setting them to strtok so we can use them as parameters of our command
    
GetPlayerName(id,n,MAX_PLAYER_NAME);//getting the players name
    
format(file,sizeof(file),"Admin%s.txt",n);//formatting the file
    
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");//if the player is not rcon admin
    
if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");// if the string is empty
    
if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID"); //if the id is not connected
    
PInfo[id][Level] = level;//sets the level of the player
    
dini_IntSet(file,"Level",level);//saves the new level to the file
    
format(str,sizeof(str),"You have set %s's level to %d",n,level);//creates the string
    
SendClientMessage(playerid,LIGHTBLUE,str);
    return 
1;

Reply
#4

Just use sscanf for getting the parameters of the command.
pawn Код:
if(sscanf(params, "ud", playerb, level)) return SendClientMessage(playerid, -1, "Usage: /setlevel [playerid] [level]"); // playerb - id of the player which will get the level
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)