#1

Hi guys i need tutorial how to use stock command like
stock player(playerid)
{
new str;
return str;
}

cuz i dont what stock does pretty much can anyone explain me pls
thx for helping !.
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=341545

https://sampwiki.blast.hk/wiki/Stocks

Search.
Reply
#3

for example like :

pawn Код:
stock Health(playerid)
{
    new Float:Health;
    GetPlayerHealth(playerid, Health);
    return Health;
}

CMD:health(playerid, params[])
{
    new String[64];
    format(String, sizeof(String), "Health : %f", Health(playerid));
    SendClientMessage(playerid, 0xFF0000FF, String);
    return 1;
}
Reply
#4

ohh nevermind i fixed 2 warnings
Reply
#5

You should use the proper tag, if you want to return a value.

For example: (from SA:MP Wiki)
pawn Код:
stock Float:Health(playerid)
{
    new Float:HP;
    GetPlayerHealth(playerid, HP);
    return HP;
}
If you replace "new" with "static" in this example, you can optimize your code (speedwise) a little bit:
pawn Код:
stock Float:Health(playerid)
{
    static Float:hp;
    GetPlayerHealth(playerid, hp);
    return hp;
}
"stock"s are basicly "scriptwise defined" functions you can use in your script. You can purely leave the "stock" keyword from this line, because what actually "stock" does is, that it removes the warnings that pops out, if this function has been never used in your script at all. "stock"s are basicly useful for includes only.

Example:
pawn Код:
Float:Health(playerid)
{
    static Float:hp;
    GetPlayerHealth(playerid, hp);
    return hp;
}
Reply
#6

ok thx !.
Reply
#7

yay i created this :
pawn Код:
#include <a_samp>
#include <zcmd>

new Str[128];

#if defined FILTERSCRIPT

public OnFilterScriptInit()

#endif

new Cars[][] =
{
    "Landstalker", "Bravura"
};

stock Vehs(vehicleid)
{
    format(Str, sizeof(Str), "%s", Cars[GetVehicleModel(vehicleid) -400]);
    return Str;
}

CMD:carnamelol(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    SendClientMessage(playerid, 0xFFFF00FF, Vehs(vehicleid));
    return 1;
}
And It Work !.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)