Public and stock
#1

Hey I can see that public and stock are almost the same, I'm a beginner, and I learned using both of them today
What's the difference between
pawn Code:
forward FreezePlayer(playerid, status);
pawn Code:
public FreezePlayer(playerid, status)
{
    switch(status)
    {
        case 0: TogglePlayerControllable(playerid, 0);
        case 1: TogglePlayerControllable(playerid, 1);
    }
}
and this
pawn Code:
stock FreezePlayer(playerid, status=0)
{
    switch(status)
    {
        case 0: TogglePlayerControllable(playerid, 0);
        case 1: TogglePlayerControllable(playerid, 1);
    }
}
A very small difference, I'm I wrong? I already made a /freeze [playerid] [1:optional (to unfreeze)] and it works with both of them after entering few modifications
Reply
#2

It's more complex, but... RESUME

public : Can be acessed by other script(Ex: CallRemoteFunction). You need to use this for timers

stock : Can be declared and not used. (I use this only in includes)

You can use
pawn Code:
FreezePlayer(playerid, status=0)
{
    switch(status)
    {
        case 0: TogglePlayerControllable(playerid, 0);
        case 1: TogglePlayerControllable(playerid, 1);
    }
}
Reply
#3

Oh god so confusing, I was using the stock in my commands and they were working fine
euhh
Reply
#4

and one other question If I want to set a timer for a kill after 10 seconds for example
Do I need to create a public function like :
pawn Code:
forward SetPlayerHealthTo0(playerid, Float:health);
public SetPlayerHealthTo0(playerid, Float:health)
{
  SetPlayerHealth(playerid, 0);
}
//
SetTimer("SetPlayerHealthTo0", 10000, false);
can't just use SetPlayerHealth in the timer?
Please Give me an answer on both last replies
thanks I need it
Reply
#5

If you are USING the functions in your commands, you don't need to use stock.

Ex:
pawn Code:
FreezePlayer(playerid, status=0)
Yes, for timers, use PUBLIC

PS: For functions with parameters, use SetTimerEx.
Reply
#6

I'm sorry If i'm disturbing you with my stupid question but with timers, even if its a already defined function, I need to make a new one? and It have to be publice, is that it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)