add player score - 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: add player score (
/showthread.php?tid=175623)
add player score -
HardMode - 10.09.2010
Hello
I need some help i want to add one point to players score when a player make a stunt.. is there any callback or function i can use to make it? I can figure how to save it then but i need some help with this
Thank you
Re: add player score -
MadeMan - 10.09.2010
pawn Код:
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
Re: add player score -
HardMode - 10.09.2010
Thats useful but wheree or how i can add it i cant figure how to add it when players make stunts
Re: add player score -
MadeMan - 10.09.2010
If you mean the stunts like in single player then I don't think there is a callback or anything for that.
Re: add player score -
Vince - 10.09.2010
You got to detect when they receive money from a stunt or something, and set the score accordingly.
If there are other possibilities for players to get money while they're in a car, it becomes increasingly difficult.
Otherwise, you could do something like:
(This is untested)
pawn Код:
new OldMoney[MAX_PLAYERS];
forward OnPlayerPerformedStunt(playerid, cash);
public OnPlayerUpdate(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
new
NewMoney = GetPlayerMoney(playerid);
if(NewMoney > OldMoney[playerid])
{
OnPlayerPerformedStunt(playerid, (NewMoney - OldMoney[playerid]) );
OldMoney[playerid] = NewMoney; // Sync the money again
}
}
return 1;
}
public OnPlayerPerformedStunt(playerid, cash)
{
new
score = floatround(cash/100, floatround_floor); // imagine that you recieve 312$ from a stunt. You will gain 3 points
SetPlayerScore(playerid, GetPlayerScore(playerid)+score);
return 1;
}
Re: add player score -
playbox12 - 10.09.2010
Nice one Vince, just needed it. Couldn't be arsed to think of it myself