Stuck here. -
Glossy42O - 05.01.2015
I wanna make setlevel but i'm kinda stuck..
PHP код:
CMD: setlevel(playerid, params[])
{
if(IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}You're not rcon administrator!");
else
{
new alevel;
new name[MAX_PLAYER_NAME], str[128];
if(sscanf(params, "ui", alevel)) return SendClientMessage(playerid, -1, "{FF0000}[ERROR]: You're not rcon administrator.");
if(!IsPlayerConnected(playerid))
return SendClientMessage(playerid, -1, "{FF0000}[Error]: Player is not connected");
can someone help me ?
Re: Stuck here. -
Schneider - 05.01.2015
You're giving the "no-admin" error message to admins...
you also sending a no-admin error message when the player enters no params
you are also using sscanf wrong.
Re: Stuck here. -
Glossy42O - 05.01.2015
ah i'm new, could u help me i really tried to search a tutorial..
Re: Stuck here. -
Schneider - 05.01.2015
Here is a good zcmd and sscanf tutorial:
https://sampforum.blast.hk/showthread.php?tid=300397
Re: Stuck here. -
Glossy42O - 05.01.2015
That'll also help me finish my cmd ?
Re: Stuck here. -
Lordzy - 05.01.2015
I think this tutorial explains more with examples that could help you create this command -
https://sampforum.blast.hk/showthread.php?tid=280476
Re: Stuck here. -
HY - 05.01.2015
pawn Код:
CMD:setlevel(playerid, params[])
{
new alevel, ID, name[MAX_PLAYER_NAME], pname[MAX_PLAYER_NAME], str[128];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}[ERROR]: You're not rcon administrator.");
if(sscanf(params, "ui", ID, alevel)) return SendClientMessage(playerid, -1, "{FF0000}USAGE: {FFFFFF}/SetLevel [Player ID] [Level]");
if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}That player isn't connected.");
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(ID, pname, sizeof(pname));
format(str, sizeof(str), "{FF0000}[INFO]: {FFFFFF}Administrator {FF0000}%s {FFFFFF}has setted your Admin Level to {FF0000}%i.", name, alevel);
SendClientMessage(ID, -1, str);
format(str, sizeof(str), "{FF0000}[INFO]: {FFFFFF}You made player {FF0000}%s {FFFFFF}Admin Level {FF0000}%i.", pname, alevel);
SendClientMessage(playerid, -1, str);
YourAdminVariableRightHere = alevel;
return 1;
}
Actually, I did this fast. It's not very optimized, because I don't have you Admin Variable.
You can use something like:
pawn Код:
if(alevel == YourAdminVariable) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}That player already has that level.");
or something like:
pawn Код:
if(alevel > Your Max. Level) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}Invalid Level.");
Cheers.
Re: Stuck here. -
Schneider - 05.01.2015
After reading that at least you will know how to use use sscanf.
But don't get me wrong, I could give you the complete working code, but then you won't learn anything. It's better to let you figure out the problem yourself and you will learn a lot more!
Here are a few tips:
- You don't have to use 'else'.
- You forgot to add a parameter in the sscanf function (read the tutorial for that).
- The second error-message should say somethink like "[Error]: Use: /setlevel [playerid] [level]".
- Don't forget to actually change the playerlevel.
Re: Stuck here. -
Glossy42O - 05.01.2015
Quote:
Originally Posted by HY
pawn Код:
CMD:setlevel(playerid, params[]) { new alevel, ID, name[MAX_PLAYER_NAME], pname[MAX_PLAYER_NAME], str[128]; if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}[ERROR]: You're not rcon administrator."); if(sscanf(params, "ui", ID, alevel)) return SendClientMessage(playerid, -1, "{FF0000}USAGE: {FFFFFF}/SetLevel [Player ID] [Level]"); if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}That player isn't connected."); GetPlayerName(playerid, name, sizeof(name)); GetPlayerName(ID, pname, sizeof(pname)); format(str, sizeof(str), "{FF0000}[INFO]: {FFFFFF}Administrator {FF0000}%s {FFFFFF}has setted your Admin Level to {FF0000}%i.", name, alevel); SendClientMessage(ID, -1, str); format(str, sizeof(str), "{FF0000}[INFO]: {FFFFFF}You made player {FF0000}%s {FFFFFF}Admin Level {FF0000}%i.", pname, alevel); SendClientMessage(playerid, -1, str); YourAdminVariableRightHere = alevel; return 1; }
Actually, I did this fast. It's not very optimized, because I don't have you Admin Variable.
You can use something like:
pawn Код:
if(alevel == YourAdminVariable) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}That player already has that level.");
or something like:
pawn Код:
if(alevel > Your Max. Level) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}Invalid Level.");
Cheers.
|
Works perfectly, but in my ban/kick command it says "You need to be level 2 etc.."
Re: Stuck here. -
Schneider - 05.01.2015
*sigh* Why am I even trying to help you...? You just keep on copy/pasting stuff from other people, still not knowing how it actually works and yes, then you get these questions.... You won't learn anything this way.