How do i create this function? - 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: How do i create this function? (
/showthread.php?tid=171062)
How do i create this function? -
mrcoolballs - 25.08.2010
Im trying to add a level system to a gamemode which runs on how many points a player has, i have made a variable called PlayerInfo[playerid][Points] now how would i go about creating a function GivePlayerPoints(playerid,points) and what about GetPlayerPoints

thanks
Re: How do i create this function? -
Matej_ - 25.08.2010
Do you maybe mean a GivePlayerScore and not GivePlayerPoints ?
Re: How do i create this function? -
[HUN]Jaki - 25.08.2010
https://sampwiki.blast.hk/wiki/SetPlayerScore
https://sampwiki.blast.hk/wiki/GetPlayerScore
pawn Код:
GivePlayerPoints(playerid, points){
PlayerInfo[playerid][Points] += points;
SetPlayerScore(playerid, PlayerInfo[playerid][Points]);
}
Do you mean something like this?
Re: How do i create this function? -
mrcoolballs - 25.08.2010
Yes tahts what i mean, thanks, what about GetPlayerPoints? edit: im not sure but is it suppose to return anything? like return 1 or return 0 or somehting
Re: How do i create this function? -
[HUN]Jaki - 25.08.2010
It does not have to return a value, but it can.
pawn Код:
GivePlayerPoints(playerid, points){
PlayerInfo[playerid][Points] += points;
SetPlayerScore(playerid, PlayerInfo[playerid][Points]);
return 1;
}
Re: How do i create this function? -
Cameltoe - 25.08.2010
pawn Код:
stock GetPlayerPoints(playerid) // to get player points
{
return PlayerInfo[playerid][Points];
}
stock GivePlayerPoints(playerid,points) // to add / remove player points
{
return PlayerInfo[playerid][Points] += points;
}
stock SetPlayerPoints(playerid,points) // to constant set player points to given points.
{
return PlayerInfo[playerid][Points] = points;
}