How do i create this function?
#1

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 GetPlayerPointsthanks
Reply
#2

Do you maybe mean a GivePlayerScore and not GivePlayerPoints ?
Reply
#3

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?
Reply
#4

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
Reply
#5

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;
}
Reply
#6

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)