SA-MP Forums Archive
Tutorial help!! - 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: Tutorial help!! (/showthread.php?tid=284715)



Tutorial help!! - Ofnet - 20.09.2011

I am looking for the tutorial of adding FIlter-Script in Game-mode.

Any one Help me with that?


Re: Tutorial help!! - |_ⒾⓇⓄN_ⒹⓄG_| - 20.09.2011

its the same....
the difference is mostly in "ongamemodeinit /onfilterscriptinit and exit"
if its a small script i can do it for you


Re: Tutorial help!! - Ofnet - 20.09.2011

pawn Код:
#include <a_samp>
#include <dudb>

public OnGameModeInit() SendRconCommand("exit");
public OnPlayerSpawn(playerid) LoadWeapons(playerid);
public OnFilterScriptInit() printf("Weaponsave FS loaded!");
public OnPlayerDisconnect(playerid, reason) SaveWeapons(playerid);

stock LoadWeapons(playerid)
{
    new pname[MAX_PLAYER_NAME];
    if(!GetPlayerName(playerid, pname, MAX_PLAYER_NAME)) return false;
    if(!udb_Exists(pname)) udb_Create(pname, "");
    for(new wep[8], amm[6], i; i < 13; i++)
    {
        format(amm, sizeof amm, "Ammo%d", i);
        format(wep, sizeof wep, "Weapon%d", i);
        GivePlayerWeapon(playerid, dUserINT(pname).(wep), dUserINT(pname).(amm));
    }
    return true;
}

stock SaveWeapons(playerid)
{
    new pname[MAX_PLAYER_NAME];
    if(!GetPlayerName(playerid, pname, MAX_PLAYER_NAME)) return false;
    if(!udb_Exists(pname)) udb_Create(pname, "");
    for(new wep[8], amm[6], i, cwep, camm; i < 13; i++)
    {
        format(amm, sizeof amm, "Ammo%d", i);
        format(wep, sizeof wep, "Weapon%d", i);
        GetPlayerWeaponData(playerid, i, cwep, camm);
        dUserSetINT(pname).(amm, camm);
        dUserSetINT(pname).(wep, cwep);
    }
    return true;
}
How to put that in Gamemode??


Re: Tutorial help!! - |_ⒾⓇⓄN_ⒹⓄG_| - 20.09.2011

copy paste the stocks and publics to the "end" of the gamemode
and the things inside onfilterscriptinit put inside ongamemodeinit.
this -> public OnGameModeInit() SendRconCommand("exit");
put in the same public in the gamemode.... i mean ongamemodeinit


Re: Tutorial help!! - Ofnet - 20.09.2011

Can you set that FS as style of gamemode as a example for me, and thanks for the Help.

I appreciate your Helps...


Re: Tutorial help!! - |_ⒾⓇⓄN_ⒹⓄG_| - 20.09.2011

pawn Код:
#include <a_samp>
#include <dudb>
//put the includes on the top of the gm




public OnGameModeInit()
{
    printf("Weaponsave FS loaded!");//this is not needed...its just a message
}
public OnPlayerSpawn(playerid)
{
    LoadWeapons(playerid);//put this on the gamemode function called onplayerspawn...the same
}
public OnPlayerDisconnect(playerid, reason)
{
    SaveWeapons(playerid);//put this on the gamemode function called onplayerdisconnect...the same
}



///////////////////////////this in the end of the gamemode////////////////////77
stock LoadWeapons(playerid)
{
    new pname[MAX_PLAYER_NAME];
    if(!GetPlayerName(playerid, pname, MAX_PLAYER_NAME)) return false;
    if(!udb_Exists(pname)) udb_Create(pname, "");
    for(new wep[8], amm[6], i; i < 13; i++)
    {
        format(amm, sizeof amm, "Ammo%d", i);
        format(wep, sizeof wep, "Weapon%d", i);
        GivePlayerWeapon(playerid, dUserINT(pname).(wep), dUserINT(pname).(amm));
    }
    return true;
}

stock SaveWeapons(playerid)
{
    new pname[MAX_PLAYER_NAME];
    if(!GetPlayerName(playerid, pname, MAX_PLAYER_NAME)) return false;
    if(!udb_Exists(pname)) udb_Create(pname, "");
    for(new wep[8], amm[6], i, cwep, camm; i < 13; i++)
    {
        format(amm, sizeof amm, "Ammo%d", i);
        format(wep, sizeof wep, "Weapon%d", i);
        GetPlayerWeaponData(playerid, i, cwep, camm);
        dUserSetINT(pname).(amm, camm);
        dUserSetINT(pname).(wep, cwep);
    }
    return true;
}
good luck


Re: Tutorial help!! - Ofnet - 20.09.2011

Dude, I got the same problem when I added the same you told me Now when I compile it I got that message in no time "Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase" and my AMX file size is 0.

Do you know about that problem??


Re: Tutorial help!! - |_ⒾⓇⓄN_ⒹⓄG_| - 20.09.2011

well
the pawno compiler 3.2.3664 blablabla is normal lol
that will show everytime u compile
and about the amx file...idk maybe ur script is little xd


Re: Tutorial help!! - Ofnet - 20.09.2011

When I compiling my simple gamemode without any filterscript that take time like 5 to 8 minutes then answer comes
"Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

Header size: 9808 bytes
Code size: 1656688 bytes
Data size: 26270784 bytes
Stack/heap size: 16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements:27953664 bytes"

and When I start the server which has that gamemode which edit it gave me runtime error.


Re: Tutorial help!! - |_ⒾⓇⓄN_ⒹⓄG_| - 20.09.2011

well....idk i never saw your script.im not wizard