Subtraction not working.. help please
#1

I made one vehicle system and now i added a new feature that is vehicle insurances, when a vehicle blows up the vehicle gets removed from the database and this works alright.

But now I'm trying to make a subtraction when a vehicle destroys example i got three insurances them the car blows up,
them the car goes to two insurances etc, but my code to do it got a bug and i need help to fix this out.

Here goes the code

pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{

    if(vehicleinfo[currentplayervehicle[killerid]][Insurances] == 0) //working
    {
        new query[256];
        new currentveh = GetPlayerVehicleID(killerid);
        DestroyVehicle(currentveh);
        format(query, sizeof(query),"DELETE FROM vehicles WHERE carid=%d",vehicleinfo[currentveh][id]);
        mysql_query(query);
        LoadPlayerKeys(vehicleinfo[currentveh][Owner]);
        SendClientMessage(vehicleinfo[currentveh][Owner],COLOR_RED, " Your vehicle as been destroyed\n (deleted)");
    }
    else // bug
    {   // the script of currentveh is working
        new currentveh = GetPlayerVehicleID(killerid);
        vehicleinfo[currentveh][Insurances]--; // this line is used to make one Subtraction of the insurances variable with "1"
        SaveVehicle(vehicleinfo[currentveh][id]); // saves the vehicle insurances
        DestroyVehicle(currentveh); // destroys the vehicle
        SendClientMessage(vehicleinfo[currentveh][Owner], COLOR_RED, " Your vehicle as destroyed \n one of the licenses is gone now"); //this is working how its supused :p
    }

    return 1;
}
Reply
#2

try the long version there are sometimes problems with enums, like using arrays inside an enum

pawn Код:
vehicleinfo[currentveh][Insurances] = (vehicleinfo[currentveh][Insurances] - 1);
Reply
#3

weird this is not subtracting the variable
Reply
#4

OnVehicleDeath(vehicleid, killerid) does not work properly
Reply
#5

new currentveh = vehicleid

Also
currentvehicle[killerid] should be vehicleid
Reply
#6

it is not.. my script is very complex and i got something wrong.. i printed the values and its its decreasing the values i left something in the midle and need figure it out lol, anyway ty nero it worked.
Reply
#7

This means whoever killed the vehicle is losing insurances, not the vehicle itself
Reply
#8

hm this is working now . when i print the values this match with vehicle system itself but i figured that my stock to save vehicles was buged so i created a new query update to insert the insurances when it destroys and now it works perfect
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)