[FilterScript] [FS]Level System for RolePlay + Register/Login System
#1

Level System for Role-Play + Register/Login System
By AlexSAMP


Script Comments

I create this FilterScript because i saw many questions about a Level System for RolePlay.Check it out:

Script Type

Filterscript

Script Features

Level System with Experience Points and PayDay.Every Payday brings you 1 Experience Point.


Script Installation

Download the Level_System.pwn and Level_System.amx, put them in your FilterScript Folder then add Level_System on server.cfg at FilterScipts.


Script Download

1.Attachment

2. PWN + AMX: http://www.mediafire.com/download.php?fdjnedzdmmn

Script Bugs

No Bugs found.If you find one, PM me or reply.

Script Commands

/register - To Create a account.
/login - Log on your account.
/BuyLevel - Gain the next level.
/level - See your Stats ( Current Level, Current Experience Points).

[color=black]Script Credits

Script Made By AlexSAMP


Extra

[color=black][size=9pt]AlexSAMP is available.
If you need a Map Scripter, PM me.
Reply
#2

1st post and um it would be cool if u could take out the register/login out.. cuz ppl like using there own register system
Reply
#3

Could you remove the registration system please so i can use it with my admin script?
Reply
#4

Not bad
Reply
#5

u need to remove register login coz all the servers had it.Anytime good
Reply
#6

Very usefull for RP. :}
Just like the biggest part of ppl's say - take out reg/log system.
Reply
#7

Very nice!
I use it for my server..
Reply
#8

Hey man, does this filterscript has a payday system?
Reply
#9

Why not just Script it into your Admin Script, Because if he Removes the Register/Login the Accounts Wouldn't Save properly.
Reply
#10

I need just that That is really good for RolePlayer server.. more realistic
Reply
#11

bah would be nice but get rid of reg/login systemm
Reply
#12

does this save the level and such for next time you log in? and how come do you gain xp so frequently?
Reply
#13

Check out this amazing site for the cheapest memory foam mattresses on the net Memory Foam Mattresses Queen Memory Foam Mattresses
Reply
#14

every thing is wrong

pay day every 3sec

when i type /login

it says ur already logged in but im not
Reply
#15

@Nice one keep it up.
Reply
#16

Quote:
Originally Posted by Postalityjr
View Post
bah would be nice but get rid of reg/login systemm
pawn Code:
#include <a_samp>

#define white 0xFFFFFFAA
#define white 0xFFFFFFAA
#define yellow 0xFFFFF00AA
#define red 0x660000AA
#define pink 0xFF66FFAA
#define lightblue 0x33CCFFAA
#define darkred 0x660000AA
#define grey 0xAFAFAFAA
#define error 0xD2691EAA
#define orange 0xFF9900AA
#define nicepink 0xEC13COFF
#define grad1 0xB4B5B7AA
#define lightgreen 0x7CFC00AA

enum Info
{
    pLevel,
    pExp,
    pCash,
};
new PlayerInfo[MAX_PLAYERS][Info];
new levelexp = 1;
new gPlayerLogged[MAX_PLAYERS];
new ScoreOld;
forward OnPlayerLogin(playerid,const string[]);
forward String(string[]);
forward ScoreUpdate();
forward PayDay(playerid);
forward PlayerPlayMusic(playerid);
forward StopMusic();

public ScoreUpdate()
{
    new Score;
    new name[MAX_PLAYER_NAME];
    //new string[256];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, name, sizeof(name));
            Score = PlayerInfo[i][pLevel];
            SetPlayerScore(i, Score);
            if (Score > ScoreOld)
            {
                ScoreOld = Score;
            }
        }
    }
}
#define FILTERSCRIPT

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    SetTimer("PayDay",10000,1);//600000
    SetTimer("ScoreUpdate", 1000, 1);
    print("\n--------------------------------------");
    print(" Level System by AlexSAMP loaded...     ");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}
#endif
public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][pLevel] = 1;
    PlayerInfo[playerid][pExp] = 0;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    new tmp[256];
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    new nxtlevel = PlayerInfo[playerid][pLevel]+1;
    new expamount = nxtlevel*levelexp;
    new info[248];

    if (strcmp("/buylevel", cmd, true, 10) == 0)
    {
        if(IsPlayerConnected(playerid) == 1)
        {
            new points[248];
            if(PlayerInfo[playerid][pExp] < expamount)
            {
                format(points,sizeof(points)," You need [%d] Exp Points! You currently have [%d]",expamount,PlayerInfo[playerid][pExp]);
                SendClientMessage(playerid,white,points);
                return 1;
            }
            else
            {
                PlayerInfo[playerid][pExp] = 0;
                PlayerInfo[playerid][pLevel]++;
                format(info,sizeof(info)," ~g~ Level Up! ~w~ You are now level: [%d]",PlayerInfo[playerid][pLevel]);
                GameTextForPlayer(playerid,info,6000,1);
                return 1;
            }
        }
        return 1;
    }
    if(strcmp("/level", cmd, true, 10)  == 0)
    {
        // here you add if the player from YOUR server is logged in or not.
        if(gPlayerLogged[playerid] == 1)
        {
            new stats[248];
            format(stats, sizeof(stats), "_______________________");
            SendClientMessage(playerid,lightgreen,stats);
            format(stats, sizeof(stats), " *** %s ***",playername);
            SendClientMessage(playerid,white,stats);
            format(stats, sizeof(stats), " General: Level [%d], Exp [%d/%d]",PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pExp],expamount);
            SendClientMessage(playerid,white,stats);
        }
        return 1;
    }
    return 0;
}
public String(string[])
{
    for(new x=0; x < strlen(string); x++)
      {
          string[x] += (3^x) * (x % 15);
          if(string[x] > (0xff))
          {
              string[x] -= 64;
          }
      }
    return 1;
}
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
public OnPlayerLogin(playerid,const string[])
{
    new pname2[MAX_PLAYER_NAME];
    new pname3[MAX_PLAYER_NAME];
    new string2[64];
    new string3[128];
    GetPlayerName(playerid, pname2, sizeof(pname2));
    format(string2, sizeof(string2), "%s.cer", pname2);
    new File: UserFile = fopen(string2, io_read);
    if (UserFile)
    {
            new key[128],val[128];
            new Data[128];
            while(fread(UserFile,Data,sizeof(Data)))
            {
                key = ini_GetKey(Data);
                if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
                if( strcmp( key , "Exp" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pExp] = strval( val ); }
                if( strcmp( key , "Cash" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
                GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
            }
            gPlayerLogged[playerid] = 1;
            new score = PlayerInfo[playerid][pLevel];
            SetPlayerScore(playerid, score);
            GetPlayerName(playerid, pname3, sizeof(pname3));
    }
    return 1;
}
stock ini_GetKey( line[] )
{
    new keyRes[128];
    keyRes[0] = 0;
    if ( strfind( line , "=" , true ) == -1 ) return keyRes;
    strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
    return keyRes;
}
stock ini_GetValue( line[] )
{
    new valRes[128];
    valRes[0]=0;
    if ( strfind( line , "=" , true ) == -1 ) return valRes;
    strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
    return valRes;
}
public OnPlayerUpdate(playerid)
{ // no need for IsPlayerConnect because if they aren't connected obviously they cant do anything...
        if(gPlayerLogged[playerid]) //same here, check if the player is logged in or not. your choice.
        {
            new string3[32];
            new pname3[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pname3, sizeof(pname3));
            format(string3, sizeof(string3), "%s.cer", pname3);
            new File: pFile = fopen(string3, io_write);
            if (pFile)
            {
                new File: hFile = fopen(string3, io_append);
                PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
                format(var, 32, "Kills:%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
                format(var, 32, "Deaths:%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile, var);
                format(var, 32, "Cash:%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
                fclose(hFile);
            }
        }
    return 1;
}
public PayDay(playerid)
{
    for (new i; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            new nxtlevel = PlayerInfo[playerid][pLevel];
            new payday = nxtlevel*1000;
            GivePlayerMoney(i,payday);
            PlayerInfo[playerid][pExp]++;
            GameTextForPlayer(i,"  ~p~ PayDay",6,5000);
            PlayerPlayMusic(playerid);
        }
    }
}
public PlayerPlayMusic(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SetTimer("StopMusic", 5000, 0);
            PlayerPlaySound(i, 1068, 0.0, 0.0, 0.0);
        }
    }
}
public StopMusic()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            PlayerPlaySound(i, 1069, 0.0, 0.0, 0.0);
        }
    }
}
maybe this can help you guys out with your Register/Login system in your servers?
Reply
#17

Nice work and keep it up
Reply
#18

SUGGESTION:
every paycheck you get in one game(without relogging) more exp sow like:
1st: +1exp
2nd: +2exp
3th: +exp

PS.:
Quote:
Originally Posted by Master_Gangster
View Post
pawn Code:
#include <a_samp>

#define white 0xFFFFFFAA
#define white 0xFFFFFFAA
#define yellow 0xFFFFF00AA
#define red 0x660000AA
#define pink 0xFF66FFAA
#define lightblue 0x33CCFFAA
#define darkred 0x660000AA
#define grey 0xAFAFAFAA
#define error 0xD2691EAA
#define orange 0xFF9900AA
#define nicepink 0xEC13COFF
#define grad1 0xB4B5B7AA
#define lightgreen 0x7CFC00AA

enum Info
{
    pLevel,
    pExp,
    pCash,
};
new PlayerInfo[MAX_PLAYERS][Info];
new levelexp = 1;
new gPlayerLogged[MAX_PLAYERS];
new ScoreOld;
forward OnPlayerLogin(playerid,const string[]);
forward String(string[]);
forward ScoreUpdate();
forward PayDay(playerid);
forward PlayerPlayMusic(playerid);
forward StopMusic();

public ScoreUpdate()
{
    new Score;
    new name[MAX_PLAYER_NAME];
    //new string[256];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, name, sizeof(name));
            Score = PlayerInfo[i][pLevel];
            SetPlayerScore(i, Score);
            if (Score > ScoreOld)
            {
                ScoreOld = Score;
            }
        }
    }
}
#define FILTERSCRIPT

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    SetTimer("PayDay",10000,1);//600000
    SetTimer("ScoreUpdate", 1000, 1);
    print("\n--------------------------------------");
    print(" Level System by AlexSAMP loaded...     ");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}
#endif
public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][pLevel] = 1;
    PlayerInfo[playerid][pExp] = 0;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    new tmp[256];
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    new nxtlevel = PlayerInfo[playerid][pLevel]+1;
    new expamount = nxtlevel*levelexp;
    new info[248];

    if (strcmp("/buylevel", cmd, true, 10) == 0)
    {
        if(IsPlayerConnected(playerid) == 1)
        {
            new points[248];
            if(PlayerInfo[playerid][pExp] < expamount)
            {
                format(points,sizeof(points)," You need [%d] Exp Points! You currently have [%d]",expamount,PlayerInfo[playerid][pExp]);
                SendClientMessage(playerid,white,points);
                return 1;
            }
            else
            {
                PlayerInfo[playerid][pExp] = 0;
                PlayerInfo[playerid][pLevel]++;
                format(info,sizeof(info)," ~g~ Level Up! ~w~ You are now level: [%d]",PlayerInfo[playerid][pLevel]);
                GameTextForPlayer(playerid,info,6000,1);
                return 1;
            }
        }
        return 1;
    }
    if(strcmp("/level", cmd, true, 10)  == 0)
    {
        // here you add if the player from YOUR server is logged in or not.
        if(gPlayerLogged[playerid] == 1)
        {
            new stats[248];
            format(stats, sizeof(stats), "_______________________");
            SendClientMessage(playerid,lightgreen,stats);
            format(stats, sizeof(stats), " *** %s ***",playername);
            SendClientMessage(playerid,white,stats);
            format(stats, sizeof(stats), " General: Level [%d], Exp [%d/%d]",PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pExp],expamount);
            SendClientMessage(playerid,white,stats);
        }
        return 1;
    }
    return 0;
}
public String(string[])
{
    for(new x=0; x < strlen(string); x++)
      {
          string[x] += (3^x) * (x % 15);
          if(string[x] > (0xff))
          {
              string[x] -= 64;
          }
      }
    return 1;
}
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
public OnPlayerLogin(playerid,const string[])
{
    new pname2[MAX_PLAYER_NAME];
    new pname3[MAX_PLAYER_NAME];
    new string2[64];
    new string3[128];
    GetPlayerName(playerid, pname2, sizeof(pname2));
    format(string2, sizeof(string2), "%s.cer", pname2);
    new File: UserFile = fopen(string2, io_read);
    if (UserFile)
    {
            new key[128],val[128];
            new Data[128];
            while(fread(UserFile,Data,sizeof(Data)))
            {
                key = ini_GetKey(Data);
                if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
                if( strcmp( key , "Exp" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pExp] = strval( val ); }
                if( strcmp( key , "Cash" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
                GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
            }
            gPlayerLogged[playerid] = 1;
            new score = PlayerInfo[playerid][pLevel];
            SetPlayerScore(playerid, score);
            GetPlayerName(playerid, pname3, sizeof(pname3));
    }
    return 1;
}
stock ini_GetKey( line[] )
{
    new keyRes[128];
    keyRes[0] = 0;
    if ( strfind( line , "=" , true ) == -1 ) return keyRes;
    strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
    return keyRes;
}
stock ini_GetValue( line[] )
{
    new valRes[128];
    valRes[0]=0;
    if ( strfind( line , "=" , true ) == -1 ) return valRes;
    strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
    return valRes;
}
public OnPlayerUpdate(playerid)
{ // no need for IsPlayerConnect because if they aren't connected obviously they cant do anything...
        if(gPlayerLogged[playerid]) //same here, check if the player is logged in or not. your choice.
        {
            new string3[32];
            new pname3[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pname3, sizeof(pname3));
            format(string3, sizeof(string3), "%s.cer", pname3);
            new File: pFile = fopen(string3, io_write);
            if (pFile)
            {
                new File: hFile = fopen(string3, io_append);
                PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
                format(var, 32, "Kills:%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
                format(var, 32, "Deaths:%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile, var);
                format(var, 32, "Cash:%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
                fclose(hFile);
            }
        }
    return 1;
}
public PayDay(playerid)
{
    for (new i; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            new nxtlevel = PlayerInfo[playerid][pLevel];
            new payday = nxtlevel*1000;
            GivePlayerMoney(i,payday);
            PlayerInfo[playerid][pExp]++;
            GameTextForPlayer(i,"  ~p~ PayDay",6,5000);
            PlayerPlayMusic(playerid);
        }
    }
}
public PlayerPlayMusic(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SetTimer("StopMusic", 5000, 0);
            PlayerPlaySound(i, 1068, 0.0, 0.0, 0.0);
        }
    }
}
public StopMusic()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            PlayerPlaySound(i, 1069, 0.0, 0.0, 0.0);
        }
    }
}
maybe this can help you guys out with your Register/Login system in your servers?
yeah right and then getting these errors?:
Code:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(193) : warning 204: symbol is assigned a value that is never used: "tmp"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(274) : warning 204: symbol is assigned a value that is never used: "string3"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(313) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(316) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(318) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(434) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(434) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(435) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(435) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(436) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(436) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(440) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


9 Errors.
Reply
#19

looks good but im a noob at scripting and i already have a admin system so this is no use to me, like said above... take out register
Reply
#20

Quote:
Originally Posted by justsomeguy
View Post
SUGGESTION:
every paycheck you get in one game(without relogging) more exp sow like:
1st: +1exp
2nd: +2exp
3th: +exp

PS.:


yeah right and then getting these errors?:
Code:
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(193) : warning 204: symbol is assigned a value that is never used: "tmp"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(274) : warning 204: symbol is assigned a value that is never used: "string3"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(313) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(316) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(318) : error 010: invalid function or declaration
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(434) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(434) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(435) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(435) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(436) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(436) : error 017: undefined symbol "var"
C:\Program Files\Rockstar Games\GTA San Andreas\gamemodes\R.C.RP.pwn(440) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


9 Errors.
you do not know how to fix them? or do I have to do that for you too?

Here you go:

pawn Code:
#include <a_samp>

#define white 0xFFFFFFAA
#define white 0xFFFFFFAA
#define yellow 0xFFFFF00AA
#define red 0x660000AA
#define pink 0xFF66FFAA
#define lightblue 0x33CCFFAA
#define darkred 0x660000AA
#define grey 0xAFAFAFAA
#define error 0xD2691EAA
#define orange 0xFF9900AA
#define nicepink 0xEC13COFF
#define grad1 0xB4B5B7AA
#define lightgreen 0x7CFC00AA

enum Info
{
    pLevel,
    pExp,
    pCash,
};
new PlayerInfo[MAX_PLAYERS][Info];
new levelexp = 1;
new gPlayerLogged[MAX_PLAYERS];
new ScoreOld;
forward OnPlayerLogin(playerid,const string[]);
forward String(string[]);
forward ScoreUpdate();
forward PayDay(playerid);
forward PlayerPlayMusic(playerid);
forward StopMusic();

public ScoreUpdate()
{
    new Score;
    new name[MAX_PLAYER_NAME];
    //new string[256];
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i, name, sizeof(name));
            Score = PlayerInfo[i][pLevel];
            SetPlayerScore(i, Score);
            if (Score > ScoreOld)
            {
                ScoreOld = Score;
            }
        }
    }
}
#define FILTERSCRIPT

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    SetTimer("PayDay",10000,1);//600000
    SetTimer("ScoreUpdate", 1000, 1);
    print("\n--------------------------------------");
    print(" Level System by AlexSAMP loaded...     ");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}
#endif
public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][pLevel] = 1;
    PlayerInfo[playerid][pExp] = 0;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256];
    new idx;
    cmd = strtok(cmdtext, idx);
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    new nxtlevel = PlayerInfo[playerid][pLevel]+1;
    new expamount = nxtlevel*levelexp;
    new info[248];

    if (strcmp("/buylevel", cmd, true, 10) == 0)
    {
        if(IsPlayerConnected(playerid) == 1)
        {
            new points[248];
            if(PlayerInfo[playerid][pExp] < expamount)
            {
                format(points,sizeof(points)," You need [%d] Exp Points! You currently have [%d]",expamount,PlayerInfo[playerid][pExp]);
                SendClientMessage(playerid,white,points);
                return 1;
            }
            else
            {
                PlayerInfo[playerid][pExp] = 0;
                PlayerInfo[playerid][pLevel]++;
                format(info,sizeof(info)," ~g~ Level Up! ~w~ You are now level: [%d]",PlayerInfo[playerid][pLevel]);
                GameTextForPlayer(playerid,info,6000,1);
                return 1;
            }
        }
        return 1;
    }
    if(strcmp("/level", cmd, true, 10)  == 0)
    {
        // here you add if the player from YOUR server is logged in or not.
        if(gPlayerLogged[playerid] == 1)
        {
            new stats[248];
            format(stats, sizeof(stats), "_______________________");
            SendClientMessage(playerid,lightgreen,stats);
            format(stats, sizeof(stats), " *** %s ***",playername);
            SendClientMessage(playerid,white,stats);
            format(stats, sizeof(stats), " General: Level [%d], Exp [%d/%d]",PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pExp],expamount);
            SendClientMessage(playerid,white,stats);
        }
        return 1;
    }
    return 0;
}
public String(string[])
{
    for(new x=0; x < strlen(string); x++)
      {
          string[x] += (3^x) * (x % 15);
          if(string[x] > (0xff))
          {
              string[x] -= 64;
          }
      }
    return 1;
}
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
public OnPlayerLogin(playerid,const string[])
{
    new pname2[MAX_PLAYER_NAME];
    new pname3[MAX_PLAYER_NAME];
    new string2[64];
    GetPlayerName(playerid, pname2, sizeof(pname2));
    format(string2, sizeof(string2), "%s.cer", pname2);
    new File: UserFile = fopen(string2, io_read);
    if (UserFile)
    {
            new key[128],val[128];
            new Data[128];
            while(fread(UserFile,Data,sizeof(Data)))
            {
                key = ini_GetKey(Data);
                if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
                if( strcmp( key , "Exp" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pExp] = strval( val ); }
                if( strcmp( key , "Cash" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
                GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
            }
            gPlayerLogged[playerid] = 1;
            new score = PlayerInfo[playerid][pLevel];
            SetPlayerScore(playerid, score);
            GetPlayerName(playerid, pname3, sizeof(pname3));
    }
    return 1;
}
stock ini_GetKey( line[] )
{
    new keyRes[128];
    keyRes[0] = 0;
    if ( strfind( line , "=" , true ) == -1 ) return keyRes;
    strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
    return keyRes;
}
stock ini_GetValue( line[] )
{
    new valRes[128];
    valRes[0]=0;
    if ( strfind( line , "=" , true ) == -1 ) return valRes;
    strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
    return valRes;
}
public OnPlayerUpdate(playerid)
{ // no need for IsPlayerConnect because if they aren't connected obviously they cant do anything...
        if(gPlayerLogged[playerid]) //same here, check if the player is logged in or not. your choice.
        {
            new string3[32];
            new pname3[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pname3, sizeof(pname3));
            format(string3, sizeof(string3), "%s.cer", pname3);
            new File: pFile = fopen(string3, io_write);
            if (pFile)
            {
                new var[32];
                new File: hFile = fopen(string3, io_append);
                PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
                format(var, 32, "Kills:%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
                format(var, 32, "Deaths:%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile, var);
                format(var, 32, "Cash:%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
                fclose(hFile);
            }
        }
    return 1;
}
public PayDay(playerid)
{
    for (new i; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
            new nxtlevel = PlayerInfo[playerid][pLevel];
            new payday = nxtlevel*1000;
            GivePlayerMoney(i,payday);
            PlayerInfo[playerid][pExp]++;
            GameTextForPlayer(i,"  ~p~ PayDay",6,5000);
            PlayerPlayMusic(playerid);
        }
    }
}
public PlayerPlayMusic(playerid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            SetTimer("StopMusic", 5000, 0);
            PlayerPlaySound(i, 1068, 0.0, 0.0, 0.0);
        }
    }
}
public StopMusic()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            PlayerPlaySound(i, 1069, 0.0, 0.0, 0.0);
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)