Would this command work? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Would this command work? (
/showthread.php?tid=272181)
Would this command work? -
Shockey HD - 27.07.2011
PHP код:
CMD:setVIP(playerid, params[])
{
new victimname[MAX_PLAYER_NAME], vipname[MAX_PLAYER_NAME], viplvl, id;
if(IsPlayerAdmin(playerid))
{
if (sscanf(params, "ui", id, viplvl)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setvip [id] [viplevel]");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "System: Invalid ID");
if (viplvl > 10 || viplvl < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid vip Levels: 1-3!");
PlayerInfo[id][pVipLevel] = viplvl;
GetPlayerName(id, victimname, sizeof(victimname));
GetPlayerName(playerid, vipname, sizeof(vipname));
new str[128];
format(str,128,"System: %s [ID %d] has set %s [ID %d] admin level to %i",vipname, playerid, victimname, id, viplvl);
SendClientMessage(playerid,COLOR_GREEN,str);
return 1;
}
else return SendClientMessage(playerid,COLOR_RED," You are not allowed to use this command!");
}
Will this work?
Re: Would this command work? -
Libra_PL - 27.07.2011
Код:
if (viplvl > 10 || viplvl < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid vip Levels: 1-3!");
It looks like you can set higher level than 3...
______
You can't try this command on themself?
Re: Would this command work? -
iPLEOMAX - 27.07.2011
Don't use || when comparing between 2 values.
Use it like this:
pawn Код:
if (viplvl <= 3 && viplvl >= 0) //Correct.
//Less than or equal to 3 and bigger than or equal to 0.
if (viplvl < 3 || viplvl > 0) //Wrong.
//It means less than 3 OR more than 0. So, if you enter 151515 it IS bigger than 3 and it will continue.
Re: Would this command work? -
Burridge - 27.07.2011
pawn Код:
if (viplvl > 10 || viplvl < 0) return SendClientMessage(playerid, COLOR_RED,"System: Valid vip Levels: 1-3!");
Should be
pawn Код:
if (viplvl < 0 || viplvl > 3) return SendClientMessage(playerid, COLOR_RED,"System: Valid vip Levels: 0-3!");
I'm sure you'd want to set them to 0, if you wished to take the VIP away :P
Apart from that, taking a brief glance over it, I don't see why it won't. However it's a good idea to test it.
Re: Would this command work? -
Shockey HD - 27.07.2011
I just took my SetAdmin code and converted it to VIP and i was in a rush so i forgot to change it from 10 to 3. Thanks guys
Re: Would this command work? -
Calgon - 27.07.2011
You should test code yourself, instead of asking others if it will work.
But given the fact that you've created this thread - it's more appropriate to refrain from case sensivity with the definition of commands.