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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)