Stock bug
#1

Код:
stock CheckAdmin(playerid)
{
	if(playerVariables[playerid][pAdminLevel] == 0) return SCM(playerid, -1, AdminOnly);
	return 1;
}
This stock should check wether you're and admin or not.
However, when I use this stock in a command, it returns the "AdminOnly" message, but it won't cancel the command to be run.
How could I fix this? I've tried doing return 0 instead of return 1, but that didn't work either.
Reply
#2

You have to cancel the process manually (inside the command).

Nonetheless, it's a function, not a stock.
Reply
#3

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
You have to cancel the process manually (inside the command).

Nonetheless, it's a function, not a stock.
Hmm. The current code that I have is this:
Код:
#define check_admin CheckAdmin(playerid);
Код:
stock CheckAdmin(playerid)
{
	if(playerVariables[playerid][pAdminLevel] == 0) return SCM(playerid, -1, AdminOnly);
	return 1;
}
I want to make it so when I have an admin command, I could do this so I wouldn't have to do the check "If(admin[playerid] == 0) return SendClientMessage(playerid, -1, "You're not an admin");":

Код:
CMD:admincommand(playerid, params[])
{
     check_admin
     //rest of code
     return 1;
}
Reply
#4

pawn Код:
stock CheckAdmin(playerid)
{
    if(playerVariables[playerid][pAdminLevel] == 0) return SCM(playerid, -1, AdminOnly), 0;
    return 1;
}
pawn Код:
CMD:admincommand(playerid, params[])
{
     if(check_admin)
     {
         //rest of code
     }
     return 1;
}
Reply
#5

This is bad practice to define a macro to call a stock function. What the point of the stock function if your calling it from macro? This seems pointless, so don't use it.

Simply call the stock as it was meant to be called. SickAttack has already given you the code you need, however if you want to shorten it then use this.

Код:
CMD:admincommand(playerid, params[])
{
     if( !CheckAdmin( playerid ) ) return 1; // this is the shorthand way of making an if statment, no need for braces;
     
     // Rest of your code goes here

     return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)