/setlevel help please -
shubham20 - 06.04.2014
this is my /setlevel cmd. either i increase or decrease level it says promoted but it should say promoted when i increase level and demoted when i decrease level please help me.
CMD
etlevel(playerid, params[])
{
new level, aname[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][AdminLevel] != 10) return SendClientMessage(playerid, COLOR_RED, "You must be a Lvl 10 Admin to use this command!");
new targetid;
if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /setlevel [PlayerID][Level]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not connected to the server");
if(level < 0 || level > 10) return SendClientMessage(playerid, COLOR_RED, "Admin Level Range Is From 0 To 10");
if(targetid != INVALID_PLAYER_ID)
{
new string1[90], tname[MAX_PLAYER_NAME], string2[90], file[300];
PlayerInfo[targetid][AdminLevel]=level;
GetPlayerName(targetid, tname, sizeof(tname));
format(file,sizeof(file),"nAdmin/Users/%s.ini",tname);
dini_IntSet(file,"AdminLevel",level);
GetPlayerName(playerid, aname, sizeof(aname));
format(string1, sizeof(string1), "Admin %s has set your Admin level to %i", aname, level);
SendClientMessage(targetid, COLOR_GREEN, string1);
GameTextForPlayer(targetid, "Promoted!", 2000, 5);
format(string2, sizeof(string1), "{00FF00}Admin %s has set %s's Admin level to %i", aname, tname, level);
SendClientMessageToAll(COLOR_YELLOW, string2);
GameTextForPlayer(targetid, "Demoted!", 2000, 5);
SendCommandToAdmins(playerid,"/setlevel");
format(string1, sizeof(string1), "%s has set %s's Admin Level to %d", aname, tname, level);
SaveIn("SetLevelLog",string1);
}
else return SendClientMessage(playerid, COLOR_RED, "ERROR: invalid playerid");
return 1;
}
Re: /setlevel help please -
ReD_HunTeR - 06.04.2014
try this ?
pawn Код:
CMD:setlevel(playerid, params[])
{
new level, aname[MAX_PLAYER_NAME], targetid, string1[90], tname[MAX_PLAYER_NAME], string2[90], file[300];
if(PlayerInfo[playerid][AdminLevel] != 10) return SendClientMessage(playerid, COLOR_RED, "You must be a Lvl 10 Admin to use this command!");
if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /setlevel [PlayerID][Level]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not connected to the server");
if(level < 0 || level > 10) return SendClientMessage(playerid, COLOR_RED, "Admin Level Range Is From 0 To 10");
if(targetid != INVALID_PLAYER_ID) return return SendClientMessage(playerid, COLOR_RED, "ERROR: invalid playerid");
GetPlayerName(targetid, tname, sizeof(tname));
GetPlayerName(playerid, aname, sizeof(aname));
format(string1, sizeof(string1), "Admin %s has set your Admin level to %i", aname, level);
SendClientMessage(targetid, COLOR_GREEN, string1);
format(string2, sizeof(string1), "{00FF00}Admin %s has set %s's Admin level to %i", aname, tname, level);
SendClientMessageToAll(COLOR_YELLOW, string2);
SendCommandToAdmins(playerid,"/setlevel");
format(string1, sizeof(string1), "%s has set %s's Admin Level to %d", aname, tname, level);
SaveIn("SetLevelLog",string1);
if(level > PlayerInfo[targetid][AdminLevel]) return GameTextForPlayer(targetid, "Promoted!", 2000, 5);
else if(level < PlayerInfo[targetid][AdminLevel]) return GameTextForPlayer(targetid, "Demoted!", 2000, 5);
PlayerInfo[targetid][AdminLevel]=level;
format(file,sizeof(file),"nAdmin/Users/%s.ini",tname);
dini_IntSet(file,"AdminLevel",level);
return 1;
}
Re: /setlevel help please -
shubham20 - 06.04.2014
no now it doesn't show anything. please help dude
Re: /setlevel help please -
ReD_HunTeR - 06.04.2014
do this work?
pawn Код:
CMD:setlevel(playerid, params[])
{
new level, aname[MAX_PLAYER_NAME], targetid, string1[90], tname[MAX_PLAYER_NAME], string2[90], file[300];
if(PlayerInfo[playerid][AdminLevel] < 10) return SendClientMessage(playerid, COLOR_RED, "You must be a Lvl 10 Admin to use this command!");
if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /setlevel [PlayerID][Level]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not connected to the server");
if(level < 0 || level > 10) return SendClientMessage(playerid, COLOR_RED, "Admin Level Range Is From 0 To 10");
if(targetid != INVALID_PLAYER_ID) return return SendClientMessage(playerid, COLOR_RED, "ERROR: invalid playerid");
GetPlayerName(targetid, tname, sizeof(tname));
GetPlayerName(playerid, aname, sizeof(aname));
format(string1, sizeof(string1), "Admin %s has set your Admin level to %i", aname, level);
SendClientMessage(targetid, COLOR_GREEN, string1);
format(string2, sizeof(string1), "{00FF00}Admin %s has set %s's Admin level to %i", aname, tname, level);
SendClientMessageToAll(COLOR_YELLOW, string2);
SendCommandToAdmins(playerid,"/setlevel");
format(string1, sizeof(string1), "%s has set %s's Admin Level to %d", aname, tname, level);
SaveIn("SetLevelLog",string1);
if(level > PlayerInfo[targetid][AdminLevel])
{
GameTextForPlayer(targetid, "Promoted!", 2000, 5);
}
else if(level < PlayerInfo[targetid][AdminLevel])
{
GameTextForPlayer(targetid, "Demoted!", 2000, 5);
}
PlayerInfo[targetid][AdminLevel]=level;
format(file,sizeof(file),"nAdmin/Users/%s.ini",tname);
dini_IntSet(file,"AdminLevel",level);
return 1;
}
Re: /setlevel help please -
shubham20 - 06.04.2014
It says there is an invalid expression in this line
pawn code:
if(targetid != INVALID_PLAYER_ID) return return SendClientMessage(playerid, COLOR_RED, "ERROR: invalid playerid");
Re: /setlevel help please -
ReD_HunTeR - 06.04.2014
hope this work
pawn Код:
CMD:setlevel(playerid, params[])
{
new level, aname[MAX_PLAYER_NAME], targetid, string1[90], tname[MAX_PLAYER_NAME], string2[90], file[300];
if(PlayerInfo[playerid][AdminLevel] < 10) return SendClientMessage(playerid, COLOR_RED, "You must be a Lvl 10 Admin to use this command!");
if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /setlevel [PlayerID][Level]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not connected to the server");
if(level < 0 || level > 10) return SendClientMessage(playerid, COLOR_RED, "Admin Level Range Is From 0 To 10");
if(targetid != INVALID_PLAYER_ID)
{
GetPlayerName(targetid, tname, sizeof(tname));
GetPlayerName(playerid, aname, sizeof(aname));
format(string1, sizeof(string1), "Admin %s has set your Admin level to %i", aname, level);
SendClientMessage(targetid, COLOR_GREEN, string1);
format(string2, sizeof(string1), "{00FF00}Admin %s has set %s's Admin level to %i", aname, tname, level);
SendClientMessageToAll(COLOR_YELLOW, string2);
SendCommandToAdmins(playerid,"/setlevel");
format(string1, sizeof(string1), "%s has set %s's Admin Level to %d", aname, tname, level);
SaveIn("SetLevelLog",string1);
if(level > PlayerInfo[targetid][AdminLevel])
{
GameTextForPlayer(targetid, "Promoted!", 2000, 5);
}
else if(level < PlayerInfo[targetid][AdminLevel])
{
GameTextForPlayer(targetid, "Demoted!", 2000, 5);
}
PlayerInfo[targetid][AdminLevel]=level;
format(file,sizeof(file),"nAdmin/Users/%s.ini",tname);
dini_IntSet(file,"AdminLevel",level);
return 1;
}
else SendClientMessage(playerid, COLOR_RED, "ERROR: invalid playerid");
}
Re: /setlevel help please -
shubham20 - 06.04.2014
no dude now there are 4 new errors
Re: /setlevel help please -
ReD_HunTeR - 06.04.2014
this should be work now, its working for me..
pawn Код:
CMD:setlevel(playerid, params[])
{
new level, aname[MAX_PLAYER_NAME], targetid, string1[90], tname[MAX_PLAYER_NAME], string2[90], file[300];
if(PlayerInfo[playerid][AdminLevel] < 10) return SendClientMessage(playerid, COLOR_RED, "You must be a Lvl 10 Admin to use this command!");
if(sscanf(params, "ui", targetid, level)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /setlevel [PlayerID][Level]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not connected to the server");
if(level < 0 || level > 10) return SendClientMessage(playerid, COLOR_RED, "Admin Level Range Is From 0 To 10");
if(targetid != INVALID_PLAYER_ID)
{
GetPlayerName(targetid, tname, sizeof(tname));
GetPlayerName(playerid, aname, sizeof(aname));
format(string1, sizeof(string1), "Admin %s has set your Admin level to %i", aname, level);
SendClientMessage(targetid, COLOR_GREEN, string1);
format(string2, sizeof(string1), "{00FF00}Admin %s has set %s's Admin level to %i", aname, tname, level);
SendClientMessageToAll(COLOR_YELLOW, string2);
SendCommandToAdmins(playerid,"/setlevel");
format(string1, sizeof(string1), "%s has set %s's Admin Level to %d", aname, tname, level);
SaveIn("SetLevelLog",string1);
if(level > PlayerInfo[targetid][AdminLevel])
{
GameTextForPlayer(targetid, "Promoted!", 2000, 5);
}
else if(level < PlayerInfo[targetid][AdminLevel])
{
GameTextForPlayer(targetid, "Demoted!", 2000, 5);
}
PlayerInfo[targetid][AdminLevel]=level;
format(file,sizeof(file),"nAdmin/Users/%s.ini",tname);
dini_IntSet(file,"AdminLevel",level);
return 1;
}
else SendClientMessage(playerid, COLOR_RED, "ERROR: invalid playerid");
return 1;
}
Re: /setlevel help please -
shubham20 - 06.04.2014
I think u left a small thing this is the warning coming
D:\SHUBHA~1\games\GTASAN~1\GAMEMO~1\HIGHSP~1.PWN(2 7715) : warning 209: function "cmd_setlevel" should return a value
Re: /setlevel help please -
ReD_HunTeR - 06.04.2014
see the last code i show you thats fixed one i compile it now warnings, and error.
or you should type "return 1;"
like this at this line :-
pawn Код:
else SendClientMessage(playerid, COLOR_RED, "ERROR: invalid playerid");
}
to this:-
pawn Код:
else SendClientMessage(playerid, COLOR_RED, "ERROR: invalid playerid");
return 1;
}