How to take away an item from stats -
Azzeto - 27.09.2011
Some one gave me a suggestion to use KillerPoints, So I made it so when A player kills another player they get 1 Killerpoint, and then when they get enough KPS they can save up for a reward (Such as a minigun with 150 ammo, hunter, tank) but I need it so when they buy an item the Killerpoints get substracted from their current killerpoints, heres an example command
pawn Код:
CMD:buyhunter(playerid,params[]){
if(PlayerInfo[playerid][pKillPoints] < 75) return SendClientMessage(playerid,COLOR_WHITE,"You do not have enough 'KPS'");
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
CreateVehicle(425,x+3.0,y,z,0,-1,-1,5);
new string[128],i;
new name[MAX_PLAYER_NAME];
GetPlayerName(i,name,sizeof(name));
format(string,sizeof(string),"%s has just purchased a Hunter, WATCH OUT!",name);
SendClientMessage(playerid,COLOR_RED,string);
return 1;
}
Re: How to take away an item from stats -
grand.Theft.Otto - 27.09.2011
Since you're using this enumeration:
PlayerInfo[playerid][pKillPoints]
You would place it in the command and subtract a certain amount of points, so for example, if they had 75 points to buy the hunter, and you wanted them to have 0 points, you would do:
PlayerInfo[playerid][pKillPoints] = 0; // now their point amount = 0
If you want to subtract 1 point for example, you would subtract: 75 - 1 = 74
So PlayerInfo[playerid][pKillPoints] += 74; // now they have 74 points and not 75, therefore they cant purchase the hunter because they're 1 point away
Example:
pawn Код:
CMD:buyhunter(playerid,params[]){
if(PlayerInfo[playerid][pKillPoints] < 75) return SendClientMessage(playerid,COLOR_WHITE,"You do not have enough 'KPS'");
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
CreateVehicle(425,x+3.0,y,z,0,-1,-1,5);
new string[128],i;
new name[MAX_PLAYER_NAME];
GetPlayerName(i,name,sizeof(name));
format(string,sizeof(string),"%s has just purchased a Hunter, WATCH OUT!",name);
SendClientMessage(playerid,COLOR_RED,string);
PlayerInfo[playerid][pKillPoints] // add += or -= including the amount of points
return 1;
}
Hope you understood.
Re: How to take away an item from stats -
sleepysnowflake - 27.09.2011
pawn Код:
CMD:buyhunter(playerid,params[]){
if(PlayerInfo[playerid][pKillPoints] < 75) return SendClientMessage(playerid,COLOR_WHITE,"You do not have enough 'KPS'");
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
CreateVehicle(425,x+3.0,y,z,0,-1,-1,5);
new string[128],i;
new name[MAX_PLAYER_NAME];
GetPlayerName(i,name,sizeof(name));
format(string,sizeof(string),"%s has just purchased a Hunter, WATCH OUT!",name);
SendClientMessage(playerid,COLOR_RED,string);
PlayerInfo[playerid][pKillPoints] = (PlayerInfo[playerid][pKillPoints] - 75);
return 1;
}
Re: How to take away an item from stats -
grand.Theft.Otto - 27.09.2011
Or you could do Berlovan's simple way ^ lmao
I made mine complicated that even I could barely understand it :S
Re: How to take away an item from stats -
Azzeto - 27.09.2011
Thank you both, rep for you both
Re: How to take away an item from stats -
sleepysnowflake - 27.09.2011
Actually, Otto's one is WAAAYYYY more explained :3 I just wrote that.
Tested also. Working:
pawn Код:
main()
{
new a = 100;
a = (a - 75);
printf("%i",a);
}