returning wrong id
#1

I got one problem with this script when im playing alone the script works and returns the correct ids and values but if there are two players playing it will bug exemple. Someone else car explodes and i receibe a message saying that my car was blow up and that is not even my car someone told the public function on vehicle death its buged but i don't know if that is true of if my codes is wrong please help me fix this .

I know it is a bit more them a small code but this requires this size.

All help are apreciated Thank you!

pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
    new query[256];
    new currentveh[MAX_PLAYERS];
    currentveh[killerid] = GetPlayerVehicleID(killerid);
    if(IsPlayerConnected(vehicleinfo[currentveh[killerid]][Owner]))
    {
        playerinfo[vehicleinfo[currentveh[killerid]][Owner]][vkey] = 0;
        currentplayervehicle[vehicleinfo[currentveh[killerid]][Owner]] = 0;
    }
    else if(!IsPlayerConnected(vehicleinfo[currentveh[killerid]][Owner]))
    {
        format(query, sizeof(query),"UPDATE users SET vkey=0,currentplayervehicle=0 WHERE Name='%s'",vehicleinfo[currentveh[killerid]][Owner]);
        mysql_query(query);
    }

    if(vehicleinfo[currentveh[killerid]][Insurances] == 0)
    {
        printf(" insurances = %d ", vehicleinfo[currentveh[killerid]][Insurances]);
        DestroyVehicle(currentveh[killerid]);
        format(query, sizeof(query),"DELETE FROM vehicles WHERE carid=%d",vehicleinfo[currentveh[killerid]][id]);
        mysql_query(query);
        LoadPlayerKeys(vehicleinfo[currentveh[killerid]][Owner]);
        SendClientMessage(vehicleinfo[currentveh[killerid]][Owner],COLOR_RED, " Your vehicle as been destroyed\n (deleted)");
    }
    else if(vehicleinfo[currentveh[killerid]][Insurances] >= 1)
    {
        vehicleinfo[currentveh[killerid]][Insurances] = (vehicleinfo[currentveh[killerid]][Insurances] - 1); // decreases one value = 1
        vehicleinfo[currentveh[killerid]][Destroyed] = (vehicleinfo[currentveh[killerid]][Destroyed] + 1);
        printf(" insurances = %d ", vehicleinfo[currentveh[killerid]][Insurances]);
        format(query, sizeof(query),"UPDATE vehicles SET Insurances=%d,TimesDestroyed=%d WHERE carid=%d",vehicleinfo[currentveh[killerid]][Insurances],vehicleinfo[currentveh[killerid]][Destroyed],vehicleinfo[currentveh[killerid]][id]);
        mysql_query(query);
        printf(" this query: %s", query);
        SendClientMessage(vehicleinfo[currentveh[killerid]][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

24 hours later anyone can help with this?
Reply
#3

Nevermind ... just checked it out in my script.
Reply
#4

uh didnt understand your awser to this topic x(
Reply
#5

Sorry, earlier I checked the OnVehicleDeath function on sa-mp wiki ... and they don`t have any 'killerid' parameter there .. so I tought that your function is wrong but then I checked it in my gamemode and apparently I have a killerid parameter .. don`t know what`s up with wiki. So yea, that`s not your problem ...
Reply
#6

yeah i need try to get a idea how to fix this out or i will need to remove some features and i dont wanna do that unfurtunaly -.-
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)