SA-MP Forums Archive
[FilterScript] System Level y Experience - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] System Level y Experience (/showthread.php?tid=616683)



System Level y Experience - FixFl0w - 09.09.2016

Excuse my English speak good Spanish 's begin ..

Based on the commentary of The Chaoz ...


Well, we started ...


Code:
new Text : LevelExp [ MAX_PLAYERS ] ;
new Float: Exp [ MAX_PLAYERS ] ;
new PlayerText : NivelSube0 ;
new PlayerText : NivelSube1 ;
new PlayerText : NivelSube2 ;
new PlayerText : NivelSube3 ;
Well then we create an enum .

Code:
enum VarUser
{
Level,
};

new User[MAX_PLAYERS][VarUser];
Then we go to the public OnPlayerDeath ..

Code:
public OnPlayerDeath(playerid, killerid, reason)
{
if(IsPlayerConnected(killerid))
{
switch(User[playerid][Level])
{
case 0:
{
Exp[killerid] += 30.22;
if(Exp[killerid] >= 100.0)
{
Exp[killerid] = 0.0;
User[killerid][Level]++;
SetTimerEx("ShowTextDrawGoesuplevel",20,false,"d",killerid);
}
}
case 1:
{
Exp[killerid] += 25.3;
if(Exp[killerid] >= 100.0)
{
Exp[killerid] = 0.0;
User[killerid][Level]++;
SetTimerEx("ShowTextDrawGoesuplevel",20,false,"d",killerid);
}
}
case 2.3:
{
Exp[killerid] += 23.5;
if(Exp[killerid] >= 100.0)
{
Exp[killerid] = 0.0;
User[killerid][Level]++;
SetTimerEx("ShowTextDrawGoesuplevel",20,false,"d",killerid);
}
}
case 4:
{
Exp[killerid] += 20.5;
if(Exp[killerid] >= 100.0)
{
Exp[killerid] = 0.0;
User[killerid][Level]++;
SetTimerEx("ShowTextDrawGoesuplevel",20,false,"d",killerid);
}
}
case 5:
{
Exp[killerid] += 20.2;
if(Exp[killerid] >= 100.0)
{
Exp[killerid] = 0.0;
User[killerid][Level]++;
SetTimerEx("ShowTextDrawGoesuplevel",20,false,"d",killerid);
}
}
case 7:
{
Exp[killerid] += 19.9;
if(Exp[killerid] >= 100.0)
{
Exp[killerid] = 0.0;
User[killerid][Level]++;
SetTimerEx("ShowTextDrawGoesuplevel",20,false,"d",killerid);
}
}
}
/// You add more ..
new string[145];
format(string,sizeof(string),"Level:  %d  Exp: %.2f",User[playerid][Nivel], Exp[playerid]);
TextDrawSetString(LevelExp[playerid],string);
TextDrawShowForPlayer(playerid, LevelExp[playerid]);
}
return 1;
}

// Every time you add for less exp . so that each level is more difficult to pass.
Now we put this textdraw that show the level and experience.

In OnGameModeInit ....

Code:
    for(new i;i<MAX_PLAYERS;i++)
    {
    LevelExp[i] = TextDrawCreate(507.199615, 92.586713, "Nivel: x exp: x");
    TextDrawLetterSize(LevelExp[i], 0.306800, 1.861333);
    TextDrawAlignment(LevelExp[i], 1);
    TextDrawColor(LevelExp[i], -1);
    TextDrawSetShadow(LevelExp[i], 0);
    TextDrawSetOutline(LevelExp[i], 1);
    TextDrawBackgroundColor(LevelExp[i], 51);
    TextDrawFont(LevelExp[i], 2);
    TextDrawSetProportional(LevelExp[i], 1);
   }
Now OnPlayerConnect
It would stay like that..


Code:
public OnPlayerConnect(playerid)
{
    // Now this, to go up a level will get a textdraw of "You've uploaded level."
    NivelSube0 = CreatePlayerTextDraw(playerid,648.399841, 167.260025, "usebox");
    PlayerTextDrawLetterSize(playerid,NivelSube0, 0.000000, 13.049262);
    PlayerTextDrawTextSize(playerid,NivelSube0, -2.799999, 0.000000);
    PlayerTextDrawAlignment(playerid,NivelSube0, 1);
    PlayerTextDrawColor(playerid,NivelSube0, -5963521);
    PlayerTextDrawUseBox(playerid,NivelSube0, true);
    PlayerTextDrawBoxColor(playerid,NivelSube0, -1061109505);
    PlayerTextDrawSetShadow(playerid,NivelSube0, 0);
    PlayerTextDrawSetOutline(playerid,NivelSube0, 0);
    PlayerTextDrawBackgroundColor(playerid,NivelSube0, 65535);
    PlayerTextDrawFont(playerid,NivelSube0, 0);

    NivelSube1 = CreatePlayerTextDraw(playerid,207.200057, 200.853332, "ЎHas subido de ~r~~r~NIVEL!");
    PlayerTextDrawLetterSize(playerid,NivelSube1, 0.711599, 3.093332);
    PlayerTextDrawAlignment(playerid,NivelSube1, 1);
    PlayerTextDrawColor(playerid,NivelSube1, -1);
    PlayerTextDrawSetShadow(playerid,NivelSube1, 0);
    PlayerTextDrawSetOutline(playerid,NivelSube1, 1);
    PlayerTextDrawBackgroundColor(playerid,NivelSube1, 51);
    PlayerTextDrawFont(playerid,NivelSube1, 3);
    PlayerTextDrawSetProportional(playerid,NivelSube1, 1);

    NivelSube2 = CreatePlayerTextDraw(playerid,471.200103, 182.933349, "+1");
    PlayerTextDrawLetterSize(playerid,NivelSube2, 0.564400, 2.675199);
    PlayerTextDrawAlignment(playerid,NivelSube2, 1);
    PlayerTextDrawColor(playerid,NivelSube2, 16711935);
    PlayerTextDrawSetShadow(playerid,NivelSube2, 0);
    PlayerTextDrawSetOutline(playerid,NivelSube2, 1);
    PlayerTextDrawBackgroundColor(playerid,NivelSube2, 51);
    PlayerTextDrawFont(playerid,NivelSube2, 3);
    PlayerTextDrawSetProportional(playerid,NivelSube2, 1);

    NivelSube3 = CreatePlayerTextDraw(playerid,198.400039, 244.159927, "Has conseguido un nuevo nivel.");
    PlayerTextDrawLetterSize(playerid,NivelSube3, 0.397199, 1.622400);
    PlayerTextDrawTextSize(playerid,NivelSube3, 1.599999, 47.786663);
    PlayerTextDrawAlignment(playerid,NivelSube3, 1);
    PlayerTextDrawColor(playerid,NivelSube3, -2139062017);
    PlayerTextDrawSetShadow(playerid,NivelSube3, 0);
    PlayerTextDrawSetOutline(playerid,NivelSube3, 1);
    PlayerTextDrawBackgroundColor(playerid,NivelSube3, 51);
    PlayerTextDrawFont(playerid,NivelSube3, 2);
    PlayerTextDrawSetProportional(playerid,NivelSube3, 1);
    return 1;
}
Then we put these

Code:
forward ShowTextDrawGoesuplevel(playerid);
public ShowTextDrawGoesuplevel(playerid)
{
PlayerTextDrawHide(playerid,NivelSube0);
PlayerTextDrawHide(playerid,NivelSube1);
PlayerTextDrawHide(playerid,NivelSube2);
PlayerTextDrawHide(playerid,NivelSube3);
SetTimerEx("HidetextdrawGoesuplevel",3000,false,"d",playerid);
return 1;
}

forward HidetextdrawGoesuplevel(playerid);
public HidetextdrawGoesuplevel(playerid)
{
PlayerTextDrawShow(playerid,NivelSube0);
PlayerTextDrawShow(playerid,NivelSube1);
PlayerTextDrawShow(playerid,NivelSube2);
PlayerTextDrawShow(playerid,NivelSube3);
return 1;
}
Now, if you do not want the textdraw

Use these commands.


Code:
CMD:mylevel(playerid,params[])
{
new string[128];
format(string,sizeof(string),"Your level is %d.",User[playerid][Level]);
SendClientMessage(playerid,-1,string);
return 1;
}

CMD:myexp(playerid,params[])
{
new string[128];
format(string,sizeof(string),"Your experience is %d.",Exp[playerid]);
SendClientMessage(playerid,-1,string);
return 1;
}

http://imgur.com/a/WES9e - image textdraw


Well you saved to your gm setear whatever you recommend them to 0 when the player is turned off and only keep the level.

Try to translate as much as possible sorry

Credits: FixFlow_ . ..

The chaoz ..

Not tell me if you find a bug .

Regards..