How to Make a Int/Float for all the players? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to Make a Int/Float for all the players? (
/showthread.php?tid=612874)
How to Make a Int/Float for all the players? -
Maheerali - 22.07.2016
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.
Re: How to Make a Int/Float for all the players? -
Freaksken - 22.07.2016
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
Re: How to Make a Int/Float for all the players? -
Maheerali - 23.07.2016
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.