Same numbers
#1

Hello guys again.

I'm having some problems while setting Tire health:

pawn Код:
if(GetPlayerSpeed(i) > 0)
                    {
                        if(TireInfo[vehicleid][Front_Left_Tire] != 0 || TireInfo[vehicleid][Front_Right_Tire] != 0 || TireInfo[vehicleid][Rear_Right_Tire] != 0 || TireInfo[vehicleid][Rear_Left_Tire] != 0)
                        {
                            if(PlayerInfo[i][Turning] == 1)
                            {
                                new string0[100],string1[100],string2[100],string3[100];
                                TireInfo[vehicleid][Front_Left_Tire] = TireInfo[vehicleid][Front_Right_Tire]-4; //Here
                                TireInfo[vehicleid][Front_Right_Tire] = TireInfo[vehicleid][Front_Right_Tire]-(2+1);//here
                                TireInfo[vehicleid][Rear_Right_Tire] = TireInfo[vehicleid][Rear_Right_Tire]-(1+3);//here
                                TireInfo[vehicleid][Rear_Left_Tire] = TireInfo[vehicleid][Rear_Left_Tire]-(3+4);//here
                                format(string0 , sizeof(string0) , "{33ff66}%d {ff0000} priekine kaire padanga.",TireInfo[vehicleid][Front_Left_Tire]);
                                format(string1 , sizeof(string1) , "{33ff66}%d {ff0000} priekine desine padanga.",TireInfo[vehicleid][Front_Right_Tire]);
                                format(string2 , sizeof(string2) , "{33ff66}%d {ff0000} galine kaire padanga.",TireInfo[vehicleid][Rear_Left_Tire]);
                                format(string3 , sizeof(string3) , "{33ff66}%d {ff0000} galine desine padanga.",TireInfo[vehicleid][Rear_Right_Tire]);
                                SendClientMessage(i,COLOR_RED,string0);
                                SendClientMessage(i,COLOR_RED,string1);
                                SendClientMessage(i,COLOR_RED,string2);
                                SendClientMessage(i,COLOR_RED,string3);
                            }
                        }
                    }
No matter what i write ,all tires health will be set to the same value , how to make it deacrease randomly?
Reply
#2

pawn Код:
TireInfo[vehicleid][Front_Left_Tire] -= random(TireInfo[vehicleid][Front_Left_Tire]);
TireInfo[vehicleid][Front_Right_Tire] -= random(TireInfo[vehicleid][Front_Right_Tire]);
TireInfo[vehicleid][Rear_Left_Tire] -= random(TireInfo[vehicleid][Rear_Left_Tire]);
TireInfo[vehicleid][Rear_Right_Tire] -= random(TireInfo[vehicleid][Rear_Right_Tire]);
Reply
#3

No , that's not what i meant...
I want to make tires health = 100
Код:
for(new i=1; i < MAX_VEHICLES; i++)
	{
 		TireInfo[i][Front_Left_Tire] = 100;
		TireInfo[i][Front_Right_Tire] = 100;
		TireInfo[i][Rear_Left_Tire] = 100;
		TireInfo[i][Rear_Right_Tire] = 100;
	}
And i want this health to decrease randomly for each tire

Like

Front_Left_Tire = 98
Front_Right_Tire = 97
Rear_Right_Tire = 95
Rear_Right_Tire = 92

and deacrese it while pressing turn which i made on OnPlayerKeyStateChange.
Reply
#4

It decreases the value of those 4 arrays. Do you want to decrease it with a limit? Like it decreases a value between 1 and 10 each time or what?

The code about decreasing should be in OnPlayerKeyStateChange.
Reply
#5

You know...Like fuel system.

PHP код:
if(GetPlayerSpeed(playerid) > 0)
    {
        if(
PRESSED(KEY_LEFT))
        {
            
PlayerInfo[playerid][Turning] = 1;
        }
        else
        {
            
PlayerInfo[playerid][Turning] = 0;
        }
        if(
PRESSED(KEY_JUMP))
        {
            
PlayerInfo[playerid][Turning] = 1;
        }
        else
        {
            
PlayerInfo[playerid][Turning] = 0;
        }
        if(
PRESSED(KEY_RIGHT))
        {
            
PlayerInfo[playerid][Turning] = 1;
        }
        else
        {
            
PlayerInfo[playerid][Turning] = 0
PHP код:
public MainTimer()
{
    new 
string[128];
    new 
Float:xFloat:yFloat:z;
    for(new 
i=0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                new 
vehicleid GetPlayerVehicleID(i);
                if(!
IsBicycle(vehicleid) && Fuel[vehicleid] > 0)
                {
                    if(
GetPlayerSpeed(i) > 0)
                    {
                        if(
TireInfo[vehicleid][Front_Left_Tire] != || TireInfo[vehicleid][Front_Right_Tire] != || TireInfo[vehicleid][Rear_Right_Tire] != || TireInfo[vehicleid][Rear_Left_Tire] != 0)
                        {
                            if(
PlayerInfo[i][Turning] == 1)
                            {
                                new 
string0[100],string1[100],string2[100],string3[100];
                                
TireInfo[vehicleid][Front_Left_Tire] -= random(TireInfo[vehicleid][Front_Left_Tire]);
                                
TireInfo[vehicleid][Front_Right_Tire] -= random(TireInfo[vehicleid][Front_Right_Tire]);
                                
TireInfo[vehicleid][Rear_Left_Tire] -= random(TireInfo[vehicleid][Rear_Left_Tire]);
                                
TireInfo[vehicleid][Rear_Right_Tire] -= random(TireInfo[vehicleid][Rear_Right_Tire]);
                                
format(string0 sizeof(string0) , "{33ff66}%d {ff0000} priekine kaire padanga.",TireInfo[vehicleid][Front_Left_Tire]); ///ERORR
                                
format(string1 sizeof(string1) , "{33ff66}%d {ff0000} priekine desine padanga.",TireInfo[vehicleid][Front_Right_Tire]); ///ERORR
                                
format(string2 sizeof(string2) , "{33ff66}%d {ff0000} galine kaire padanga.",TireInfo[vehicleid][Rear_Left_Tire]); ///ERORR
                                
format(string3 sizeof(string3) , "{33ff66}%d {ff0000} galine desine padanga.",TireInfo[vehicleid][Rear_Right_Tire]); ///ERORR
                                
SendClientMessage(i,COLOR_RED,string0);
                                
SendClientMessage(i,COLOR_RED,string1);
                                
SendClientMessage(i,COLOR_RED,string2);
                                
SendClientMessage(i,COLOR_RED,string3);
                            }
                        }
                     }
                    
//////////////////////////////////////////////
                    
Fuel[vehicleid] -= GetPlayerSpeed(i)/1000.0;
                    
////////////////////////////////////////////////////////////////
                    
if(TireInfo[vehicleid][Front_Left_Tire] <= 0)
                    {
                        new 
panelsdoorslightstires;
                        
GetVehicleDamageStatus(vehicleidpanelsdoorslightstires);
                        
UpdateVehicleDamageStatus(vehicleidpanelsdoorslights, (tires 0b1000));
                    }
                    if(
TireInfo[vehicleid][Front_Right_Tire] <= 0)
                    {
                        new 
panelsdoorslightstires;
                        
GetVehicleDamageStatus(vehicleidpanelsdoorslightstires);
                        
UpdateVehicleDamageStatus(vehicleidpanelsdoorslights, (tires 0b0010));
                    }
                    if(
TireInfo[vehicleid][Rear_Left_Tire] <= 0)
                    {
                        new 
panelsdoorslightstires;
                        
GetVehicleDamageStatus(vehicleidpanelsdoorslightstires);
                        
UpdateVehicleDamageStatus(vehicleidpanelsdoorslights, (tires 0b0100));
                    }
                    if(
TireInfo[vehicleid][Rear_Right_Tire] <= 0)
                    {
                        new 
panelsdoorslightstires;
                        
GetVehicleDamageStatus(vehicleidpanelsdoorslightstires);
                        
UpdateVehicleDamageStatus(vehicleidpanelsdoorslights, (tires 0b0001));
                    }
                }
            }
        }
    } 
Reply
#6

But i want to deacrease every tire health personally not with the same amount.
Reply
#7

random function is used. If there is a case to be the same value for those 4 arrays, that will be very rare.
Reply
#8

Those 4 arrays are setted to random ,but every array is set to the same number like:

Front_Left_Tire = 1
Front_Right_tire = 1
Rear_Left_Tire = 1
Rear_Right_tire = 1

but i want to make it random to every array:


Front_Left_Tire = 5
Front_Right_tire = 2
Rear_Left_Tire = 7
Rear_Right_tire = 4

Like this.
Reply
#9

PHP код:
    TireInfo[vehicleid][Front_Left_Tire] -= TireInfo[vehicleid][Front_Left_Tire]-random(3);
                                
TireInfo[vehicleid][Front_Right_Tire] -= TireInfo[vehicleid][Front_Right_Tire]-random(3);
                                
TireInfo[vehicleid][Rear_Left_Tire] -= TireInfo[vehicleid][Rear_Left_Tire]-random(3);
                                
TireInfo[vehicleid][Rear_Right_Tire] -= TireInfo[vehicleid][Rear_Right_Tire]-random(3); 
Tried like this still not working...
Reply
#10

it would be like this
pawn Код:
TireInfo[vehicleid][Front_Left_Tire] -= random(3);
TireInfo[vehicleid][Front_Right_Tire] -= random(3);
TireInfo[vehicleid][Rear_Left_Tire] -= random(3);
TireInfo[vehicleid][Rear_Right_Tire] -= random(3);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)