SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 19/03/2011, 03:19 AM   #1
sciman001
Gangsta
 
Join Date: Jan 2011
Location: C:/Your Mom/Her Fat Ass/me.amx
Posts: 642
Reputation: 9
Default Functions?

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?
__________________
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
sciman001 is offline  
Old 19/03/2011, 03:22 AM   #2
PinkFloydLover
Huge Clucker
 
Join Date: Dec 2007
Location: Yes
Posts: 248
Reputation: 12
Default Re: Functions?

Yes, that's how they work
PinkFloydLover is offline  
Old 19/03/2011, 03:23 AM   #3
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,831
Reputation: 668
Default AW: Functions?

Search for "Stock declarations" in pawn-language.pdf
Nero_3D is offline  
Old 19/03/2011, 03:24 AM   #4
sciman001
Gangsta
 
Join Date: Jan 2011
Location: C:/Your Mom/Her Fat Ass/me.amx
Posts: 642
Reputation: 9
Default

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;
}
__________________
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.

Last edited by JaTochNietDan; 19/03/2011 at 03:08 PM. Reason: Use the edit button
sciman001 is offline  
Old 19/03/2011, 03:38 AM   #5
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,831
Reputation: 668
Default AW: Functions?

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
Nero_3D is offline  
Old 19/03/2011, 03:57 AM   #6
sciman001
Gangsta
 
Join Date: Jan 2011
Location: C:/Your Mom/Her Fat Ass/me.amx
Posts: 642
Reputation: 9
Default

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?
__________________
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.

Last edited by JaTochNietDan; 19/03/2011 at 03:08 PM. Reason: Use the edit button
sciman001 is offline  
Old 19/03/2011, 02:28 PM   #7
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,831
Reputation: 668
Default AW: Re: Functions?

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 View Post
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
Nero_3D is offline  
Old 19/03/2011, 04:03 PM   #8
sciman001
Gangsta
 
Join Date: Jan 2011
Location: C:/Your Mom/Her Fat Ass/me.amx
Posts: 642
Reputation: 9
Default Re: Functions?

nevermind.
__________________
(\__/)
(='.'=) This is Bunny. Copy and paste Bunny into your
(")_(") signature to help him gain world domination.
sciman001 is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] [INC] LSF - Lorenc's Simple Functions (w/ gang/clan functions) Lorenc_ Includes 14 21/04/2018 05:06 AM
How to get functions? Twain32 Help Archive 4 08/10/2010 08:37 PM
[FilterScript] Useful Functions [0.3b RC2] ZaR Filterscripts 26 17/08/2010 12:10 AM
Help with car functions. Mirkan Help Archive 0 24/10/2009 02:05 PM
New functions Frement Help Archive 3 24/08/2009 09:57 PM


All times are GMT. The time now is 09:35 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.