SA-MP Forums Archive
Need 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need Help :/ (/showthread.php?tid=157642)



Need Help :/ - Lorenc_ - 07.07.2010

Hello, Im making a xp system out of dini. Now im unsure how to do something..
how can i make a function called GivePlayerXp(playerid, xpamount); out of
PlayerInfo[playerid][pExp]++;?

or is there any other way?
Please help me :P

-Lorenc


Re: Need Help :/ - dice7 - 07.07.2010

pawn Код:
GivePlayerXp(playerid, amount)
{
    PlayerInfo[playerid][pExp] = PlayerInfo[playerid][pExp] + amount;
}



Re: Need Help :/ - Lorenc_ - 07.07.2010

Dice your the best !!!! Thanks so much


Re: Need Help :/ - Lorenc_ - 07.07.2010

Now i need to know one more thing. How do i Make GetPlayerXp??


Re: Need Help :/ - CAR - 07.07.2010

pawn Код:
GetPlayerXp(playerid)
{    
   return PlayerInfo[playerid][pExp];
}
Isn't it?


Re: Need Help :/ - Lorenc_ - 07.07.2010

Might work, I think its like that 100%.

But when i use this

pawn Код:
GivePlayerXp(playerid, amount)
{
    PlayerInfo[playerid][pExp] = PlayerInfo[playerid][pExp] + amount;
}
How do i make it update the textdraw string
I mean where do i put this to update the exp textdraw
pawn Код:
new string[128];
    format(string, sizeof(string), "XP: %d", PlayerInfo[playerid][pExp]);
    TextDrawSetString(TDSTATS[playerid], string);
    TextDrawShowForPlayer(playerid, TDSTATS[playerid]);



Re: Need Help :/ - CAR - 07.07.2010

pawn Код:
new string[128];
    format(string, sizeof(string), "XP: %d", GetPlayerXp(playerid)); //<<here
    TextDrawSetString(TDSTATS[playerid], string);
    TextDrawShowForPlayer(playerid, TDSTATS[playerid]);



Re: Need Help :/ - Lorenc_ - 07.07.2010

No I mean wat i done is correct but i just cant get it to update the exp when the person gains the exp. It updates every spawn which i dont want it to be.

My OnPlayerSpawn Code

pawn Код:
public OnPlayerSpawn(playerid)
{
    XPTDLoad(playerid);
    new string[128];
    format(string, sizeof(string), "XP: %d", PlayerInfo[playerid][pExp]);
    TextDrawSetString(TDSTATS[playerid], string);
    TextDrawShowForPlayer(playerid, TDSTATS[playerid]);
    return 1;
}
I had never made one of this xp systems b4 :P


Re: Need Help :/ - CAR - 07.07.2010

EDIT: now it's updating every second

pawn Код:
forward PlayerXPTimer(playerid);

public PlayerXPTimer(playerid)
{
   new string[128];
   TextDrawHideForPlayer(playerid, TDSTATS[playerid]);
   format(string, sizeof(string), "XP: %d", GetPlayerXp(playerid));    
   TextDrawSetString(TDSTATS[playerid], string);    
   TextDrawShowForPlayer(playerid, TDSTATS[playerid]);
}

public OnPlayerSpawn(playerid)
{
   SerTimerEx("PlayerXPTimer", 1000, true, "d", playerid);
   return 1;
}



Re: Need Help :/ - KnooL - 07.07.2010

When does the player gains his XP?