#1

HEllo!
I have this code
Код:
new Vehcolor1 = randomEx(0,255);
new Vehcolor2 = randomEx(0,255);
Why pawno wonts to compile (crash)

I use them like

Код:
veh1[playerid] = CreateVehicle(model,x+1,y+1,z,a,Vehcolor1,Vehcolor2,-1);
...
....
....
Reply
#2

try this:

Код:
new vehcolor1 = random(255);
new vehcolor2 = random(255);

veh1[playerid] = CreateVehicle(model,x+1,y+1,z,a,vehcolor1,vehcolor2,-1);
...
...
...
Reply
#3

No its not working
Problem is in this
Код:
randomEx(0,255)....
Код:
stock randomEx(min, max)
{
new rand = random(max-min)+min;
return rand;
}
Reply
#4

You cannot call functions while declaring global variables.

This code won't work:
Код:
new global_var = random(255);
main()
{

}
Correct Way
Код:
new global_var;
main()
{
    global_var = random(255);
}
But you can call functions while declaring local variables.This code will work:
Код:
main()
{
    new global_var = random(255);
}
Reply
#5

I use it for vehicle saving system soo I need them like that to store the color
Reply
#6

You can't assign values by calling functions when you declare variables in the global scope.

Add these to main():
Код:
vehcolor1 = random(255);
new vehcolor2 = random(255);
Change this:
Код:
new Vehcolor1 = randomEx(0,255);
new Vehcolor2 = randomEx(0,255);
to

Код:
new Vehcolor1;
new Vehcolor2;
Reply
#7

fixed
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)