How to Make a Int/Float for all the players?
#3

Quote:
Originally Posted by Freaksken
Посмотреть сообщение
If you want to keep all VehicleRepairs of all players, WITHOUT knowing which player did how many repairs,
you can just use a normal integer.
Код:
//Top of script
new VehicleRepairs;
If you want to keep all VehicleRepairs of all players, WITH knowing which player did how many repairs,
that's where arrays are needed.
For integers:
Код:
//Top of script
new VehicleRepairs[MAX_PLAYERS]; //An array that keeps the amount of vehicle repairs for every player

//Assignement
VehicleRepairs[playerid]++; //Previous value + 1
VehicleRepairs[playerid] += 5; //Previous value + 5
VehicleRepairs[playerid] = 5; //Overwrite previous value with 5

//Conditional check
if(VehicleRepairs[playerid] == 0) {
    //No repairs
}
To use an array with a tag (such as Float:, bool:, ...):
Код:
//Top of script
//Use:
new Float:MyVariable[MAX_PLAYERS];
//Instead of
new MyVariable[MAX_PLAYERS];
//Everything else stays the same
How to define this.
Reply


Messages In This Thread
How to Make a Int/Float for all the players? - by Maheerali - 22.07.2016, 13:09
Re: How to Make a Int/Float for all the players? - by Freaksken - 22.07.2016, 14:53
Re: How to Make a Int/Float for all the players? - by Maheerali - 23.07.2016, 08:54

Forum Jump:


Users browsing this thread: 1 Guest(s)