Stock - 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 (
/showthread.php?tid=547828)
Stock -
UltraScripter - 25.11.2014
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
!.
Re: Stock -
Write - 25.11.2014
https://sampforum.blast.hk/showthread.php?tid=341545
https://sampwiki.blast.hk/wiki/Stocks
Search.
Re: Stock -
UltraScripter - 25.11.2014
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;
}
Re: Stock -
UltraScripter - 25.11.2014
ohh nevermind i fixed 2 warnings
AW: Stock -
BigETI - 25.11.2014
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;
}
Re: Stock -
UltraScripter - 25.11.2014
ok thx
!.
Re: Stock -
UltraScripter - 25.11.2014
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
!.