SA-MP Forums Archive
Stock bug - 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)
+--- Thread: Stock bug (/showthread.php?tid=618692)



Stock bug - danielpalade - 09.10.2016

Код:
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.


Re: Stock bug - SickAttack - 09.10.2016

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

Nonetheless, it's a function, not a stock.


Re: Stock bug - danielpalade - 09.10.2016

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;
}



Re: Stock bug - SickAttack - 09.10.2016

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;
}



Re: Stock bug - azzerking - 09.10.2016

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;
}