Functions? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Functions? (
/showthread.php?tid=241927)
Functions? -
sciman001 - 19.03.2011
Wait a sec... does stock function(params) make a function? If so... i could do something like...
pawn Code:
stock HealPlayer(playerid)
{
SetPlayerHealth(playerid, 100;
SetPlayerAromur(playerid, 100);
}
Is that what its for?
Re: Functions? -
PinkFloydLover - 19.03.2011
Yes, that's how they work
AW: Functions? -
Nero_3D - 19.03.2011
Search for "Stock declarations" in
pawn-language.pdf
-
sciman001 - 19.03.2011
ok... ill reply in a few...
so i could do tis:
pawn Code:
stock wm(main, sub)
{
main - sub;
}
and then on like... OnPlayerConnect(playerid) i could put new main = 10; and new sub = 5; and then do um... wm(main, sub);
pawn Code:
public OnPlayerConnect(playerid)
{
new main = 10;
new main = 5;
wm(main, sub);
return 1;
}
stock wm(main, sub)
{
main - sub;
}
AW: Functions? -
Nero_3D - 19.03.2011
There is a ALMIGHTY edit botton
pawn Code:
//macro
#define add(%0,%1) ((%0) + (%1))
//normal function
add(var1, var2) return (var1 + var2);
//stock
stock add(var1, var2) return (var1 + var2);
//public
forward add(var1, var2);
public add(var1, var2) return (var1 + var2);
And how to call it
pawn Code:
main()
{
new add1 = 3;
new add2 = 7;
new result = add(add1, add2);
printf("%d + %d = %d", add1, add2, result); //3 + 7 = 10
}
if you need information about the types, its all in here ->
Pawn_Language_Guide.pdf
-
sciman001 - 19.03.2011
what about this? whatswrong with it:
pawn Code:
#include <a_samp>
main()
{
print("random crap loaded!");
}
public OnFilterScriptInit()
{
new w = 15;
new r = 12;
Func1(w, r);
return 1;
}
Func1(w, r)
{
new w = r - e;
printf("%i", w);
}
OMFG!!! I used my "knowlege" in this to make my first "include" im gonna start to make a real include. THANKS SOOOOOOO MUCH!!!!!!!!!!















Whats wrong with this?
pawn Code:
public OnPlayerConnect(playerid)
{
SendConnectMessage(playerid);
return 1;
}
public OnPlayerDicsonnect(playerid, reason)
{
SendDisconnectMessage(playerid, reason);
return 1;
}
Heres the include:
pawn Code:
SendConnectMessage(playerid)
{
new name[MAX_PLAYER_NAME], string[44];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s has joined the server.",name);
SendClientMessageToAll(0xFFFF00AA, string);
print(string);
}
SendDisconnectMessage(playerid, reason)
{
new string[64],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
switch(reason)
{
case 0: format(string,sizeof string,"%s left the server. (Timed out)",name);
case 1: format(string,sizeof string,"%s left the server. (Leaving)",name);
case 2: format(string,sizeof string,"%s left the server. (Kicked/Banned)",name);
}
SendClientMessageToAll(0xFFFFFFAA,string);
}
nevermind. how do i make it so that the player doesnt have to use all the functions if he doesnt want to?
AW: Re: Functions? -
Nero_3D - 19.03.2011
There is an
EDIT BUTTOM at the right down corner in your post, use it
Double posting is against the forum rules ->
General > Forum rules
Quote:
Originally Posted by sciman001
nevermind. how do i make it so that the player doesnt have to use all the functions if he doesnt want to?
|
What do you mean with "the player doesnt have to use all the functions" ?
What functions ? Everyone can script his gamemode how he wants
Re: Functions? -
sciman001 - 19.03.2011
nevermind.