Variable stocking
#9

Quote:
Originally Posted by KreeDz
Посмотреть сообщение
Actually, the output value is correct if i do printf("%d", carscounted); after the carscounted = CountVehicles();. And this is what makes me think that the value is defined incorrectly at the start of the script.
Код:
stock CountVehicles(){new cars;
for(new i = 0; i < 500; i++){
if(GetVehicleModel(i)!=0){
cars++;}}return cars;}
You must call this function AFTER the information relating to it. Use my example below as reference.

pawn Код:
#define macro CountVehicles()+1

stock CountVehicles()
{
    new cars;
    for(new i = 0; i < 500; i++) if(GetVehicleModel(i)!=0) cars++;
    return cars;
}

public OnGameModeInit()
{
    CreateVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, 0, 1, 60);
    printf("%d",CountVehicles());
    printf("%d",macro);
    return 1;
}
Код:
Output:
1
2
Reply


Messages In This Thread
Variable stocking - by KreeDz - 30.12.2011, 02:47
Re: Variable stocking - by Guest9328472398472 - 30.12.2011, 03:29
Re: Variable stocking - by KreeDz - 30.12.2011, 09:27
Re: Variable stocking - by KreeDz - 30.12.2011, 14:32
Re: Variable stocking - by Gh05t_ - 30.12.2011, 14:58
Re: Variable stocking - by KreeDz - 31.12.2011, 14:59
Re: Variable stocking - by Gh05t_ - 31.12.2011, 15:04
Re: Variable stocking - by KreeDz - 31.12.2011, 15:11
Re: Variable stocking - by Gh05t_ - 31.12.2011, 15:25
Re: Variable stocking - by KreeDz - 31.12.2011, 15:33

Forum Jump:


Users browsing this thread: 1 Guest(s)