30.03.2011, 23:20
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!
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;
}