Functions?
#1

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?
Reply
#2

Yes, that's how they work
Reply
#3

Search for "Stock declarations" in pawn-language.pdf
Reply
#4

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;
}
Reply
#5

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
Reply
#6

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?
Reply
#7

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
Reply
#8

nevermind.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)