22.07.2016, 13:09
I want to make an int/float for all the players which would be the number of owned VehicleRepair. How to declare this and how to use it in if Statement.
//Top of script new VehicleRepairs;
//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
}
//Top of script //Use: new Float:MyVariable[MAX_PLAYERS]; //Instead of new MyVariable[MAX_PLAYERS]; //Everything else stays the same
|
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; 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
}
Код:
//Top of script //Use: new Float:MyVariable[MAX_PLAYERS]; //Instead of new MyVariable[MAX_PLAYERS]; //Everything else stays the same |