OnVehicleDeath - how can I do?
#1

Hi. I created my vehicle system that is totally different with SA:MP's vehicles. In fact, I never use vehicleid. I have a problem. I want to set that if a vehicle death, it set to him a variable that say that it is dead. When it respawn it set a total of health.
The problem is: id = ?

"VicinoVeicolo" = IsPlayerNearVehicle -> return id;

"InVeicolo" = IsPlayerInVehicle -> return id;

but don't work neither of both.

PHP код:
public OnVehicleDeath(vehicleidkillerid)
{
    for(new 
0MAX_PLAYERSi++)
    {
        
//new id = VicinoVeicolo(i);
               //new id = InVeicolo(i);
        
if(Veicolo[id][Creato] == 1)
        {
            if(
Veicolo[id][Acquistato] == 1)
            
Veicolo[id][Distrutto] = 1;
            else 
Veicolo[id][Distrutto] = 0;
        }
    }
    
    return 
1;

Reply
#2

Hello!

Why you use a loop? You have the parameter "vehicleid".
PHP код:
public OnVehicleDeath(vehicleid,killerid)
{
    if(
Veicolo[vehicleid][Creato] == 1)
    {
        if(
Veicolo[vehicleid][Acquistato] == 1)Veicolo[vehicleid][Distrutto] = 1;
        else 
Veicolo[vehicleid][Distrutto] = 0;
    }
    return 
1;

I don't know wheather you want it so.
Reply
#3

Код:
public OnVehicleDeath(vehicleid, killerid) 
{  
	if(Veicolo[vehicleid][Acquistato] == 1) { Veicolo[vehicleid][Distrutto] = 1; }
            else Veicolo[id][Distrutto] = 0;  
    return 1; 
}
// Basic template- guy above me bet me to it, use his example
Reply
#4

Example: VEHICLEID in GAME = 5; ID of script = 1; So Vehicleid isn't ID.
Reply
#5

I do not know your system, but try this:
PHP код:
public OnVehicleDeath(vehicleid,killerid)
{
    
//new id = VicinoVeicolo(killerid);
    //new id = InVeicolo(killerid);
    
if(Veicolo[id][Creato] == 1)
    {
        if(
Veicolo[id][Acquistato] == 1)Veicolo[id][Distrutto] = 1;
        else 
Veicolo[id][Distrutto] = 0;
    }
    return 
1;

killerid is the id who killed the vehicle.
Reply
#6

EDIT
Reply
#7

After a lot of time, I created a function that will work. Thank you...
Reply


Forum Jump:


Users browsing this thread: