Good Detailed Stock Tutorials? -
Rolyy - 05.08.2011
Title says it all, I want to improve my knowledge in creating
stock's.
And I am wondering if there by any chance are good detailed & explained tutorials (with examples Etc.) for it, so far I couldn't find any tutorials based on it besides one. But it didn't help me as good as usual. So therefor I made this topic and searching for a more "advanced" one.
Page that I've already read:
https://sampwiki.blast.hk/wiki/Stocks
Thanks in Advance,
Rolyy
Re: Good Detailed Stock Tutorials? -
Riddick94 - 05.08.2011
https://sampwiki.blast.hk/wiki/Stocks
Re: Good Detailed Stock Tutorials? -
Rolyy - 05.08.2011
Quote:
Originally Posted by Rolyy
So far I couldn't find any tutorials based on it besides one. But it didn't help me as good as usual.
|
Quote:
Originally Posted by Riddick94
|
Sorry forgot to add the link at main post.
Link Added.
Re: Good Detailed Stock Tutorials? -
MadeMan - 05.08.2011
stock is a function. So you want to know how to make functions?
Re: Good Detailed Stock Tutorials? -
wups - 05.08.2011
I think there is enough info in that wiki page.
Re: Good Detailed Stock Tutorials? -
Rolyy - 05.08.2011
Quote:
Originally Posted by wups
I think there is enough info in that wiki page.
|
Not to be rude, but I am looking for a tutorial.. Not for personal opinions.
Re: Good Detailed Stock Tutorials? -
Basicz - 05.08.2011
stock is a code to make functions.
It won't send " Symbol is unused "strtok" " if you use stock.
Example :
pawn Code:
strtok( ... )
{
return 1;
}
If you didn't use it, the compiler will sends a warning except if you use
With stock, you can still add it without using it, without any warnings.
pawn Code:
stock strtok( ... )
{
return 1;
}
Don't use timers or callbacks with stock, instead use forward( ); and public( )
pawn Code:
public OnGameModeInit( )
{
SetTimer( "gmx", 3000, true );
return 1;
}
stock gmx( ) // Wrong usage
return GameModeExit( );
forward gmx( ); public gmx( ) // Correct usage
return GameModeExit( );
I think wiki is enough.
& ( if you mean &&, scroll the page below ) signs means, you need to create it's own variable first, then use the function. Like :
pawn Code:
stock getName( playerid, &szName ) // idk, if it sends a error try &szName[ 24 ]
{
GetPlayerName( playerid, szName, sizeof ( szName ) );
return name; // forgot how to do this :P
}
// Somewhere
new
name[ 24 ]
;
getName( playerid, name );
print( "%s", name );
About && sign, it means 'And'
Example:
pawn Code:
if ( ( getPlayerName( playerid ) == "Basicz" ) && ( strlen( getPlayerName( playerid ) ) == strlen( "Basicz" ) ) ) { // blablabla } // if playername == basicz and strlen playername == strlen " basicz "
if ( isANoob( playerid ) && GetPlayerMoney( playerid ) < 3500 )
return Ban( playerid ); // if isanoob && getplayermoney < 3500
A simple one.
Not really advanced, but hope this can help you.
( Im a noob too :P But hope this can help you )
Re: Good Detailed Stock Tutorials? -
Lorenc_ - 05.08.2011
stock is commonly used for functions that are created and are going to be un-used/used, therefore it will prevent an error caused by the compiler, if the 'stock' keyword is added, the compiler will ignore the function and continue its compiling, if it's used, then of course not, it wouldn't be ignored.
Quote:
For example, if you have a stock that gave the player a vehicle, but you never use it, when you go to compile the compiler wouldn't bothered including it. This makes it advantageous to have large stock libraries stored in includes, as the script will only "extract" the ones it requires upon compiling.
|
Re: Good Detailed Stock Tutorials? -
Vince - 05.08.2011
People seem to misunderstand that stock does not necessarily declares a function. It is merely a
modifier. Basicz said pretty much all of it, but you can also use stock when declaring variables;
This will not generate a warning if the variable is not used. So with that in mind:
Quote:
Originally Posted by Rolyy
I want to improve my knowledge in creating functions
|