SA-MP Forums Archive
help +rep - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help +rep (/showthread.php?tid=503194)



help +rep - TomatoRage - 28.03.2014

I've got a vehicle system which in it you don't lose your car just if someone blowed it.
and I've got this code onvehicledeath
pawn Код:
if(VehicleInfo[vehicleid][bought] == 1)
    {
        SendClientMessage(VehicleInfo[vehicleid][vOwner],COLOR_RED,"[ERROR] {FFFFFF}Your bought vehicle has been destroyed. You have to buy another one");
        fremove(VehicleFile(vehicleid));
        DestroyNeons(vehicleid);
        DestroyVehicle(vehicleid);
        GetPlayerVehicles[VehicleInfo[vehicleid][vOwner]] --;
    }
but the proplem its not sending me any message when the vehicle death and it doesn't discrease the number of owned vehicles.
I knew the problem i have to write ID not name but i don't know how to convert from name to ID can some one help me

you will get +rep


Re : help +rep - Golimad - 28.03.2014

shouldn't it be more like this : VehicleInfo[playerid][bought] And VehicleInfo[playerid][vOwner] ?


Re: help +rep - TomatoRage - 28.03.2014

VehicleInfo[playerid][bought] this means if the vehicle bought or not (not a street vehicle)
VehicleInfo[playerid][vOwner] this means the owner of the bought vehicle


Re: help +rep - newbie scripter - 28.03.2014

the enum for VehicleInfo please.


Re: help +rep - TomatoRage - 28.03.2014

pawn Код:
enum vInfo
{
    vID,
    vModel,
    vColor1,
    vColor2,
    vPrice,
    vOwner[24],
    Float:vPosX,
    Float:vPosY,
    Float:vPosZ,
    Float:vPosA,
    vPlate[32],
    vPaintJob,
    vNeons,
    Float:vHealth,
    bought,
    dspawned,
    vspawned,
    aspawned,
    bombed
}



Re: help +rep - Kirollos - 28.03.2014

Why don't you use killerid parameter in OnVehicleDeath?


Re: help +rep - TomatoRage - 28.03.2014

because i don't care about the killer i want the vehicles owner id.


Re: help +rep - jakejohnsonusa - 28.03.2014

Replace everything on your first post with this:

pawn Код:
if(VehicleInfo[vehicleid][bought] == 1)
{
      new vehownerid = GetPlayerId(VehicleInfo[vehicleid][vOwner]);
      if(vehownerid != INVALID_PLAYER_ID)
      {
            SendClientMessage(vehownerid, COLOR_RED, "[ERROR] {FFFFFF}Your bought vehicle has been destroyed. You have to buy another one");
            GetPlayerVehicles[VehicleInfo[vehicleid][vOwner]] --;
      }
      fremove(VehicleFile(vehicleid));
      DestroyNeons(vehicleid);
      DestroyVehicle(vehicleid);
}



Re: help +rep - Kirollos - 28.03.2014

Quote:
Originally Posted by TomatoRage
Посмотреть сообщение
because i don't care about the killer i want the vehicles owner id.
First of all, use this custom function https://sampwiki.blast.hk/wiki/GetPlayerID

Secondly, make a check if GetPlayerID returns -1 -> just remove the vehicle's file, because player not connected
else -> save the ID in a variable and send the client message etc.


Re: help +rep - Kirollos - 28.03.2014

Quote:
Originally Posted by jakejohnsonusa
Посмотреть сообщение
Replace everything on your first post with this:

pawn Код:
if(VehicleInfo[vehicleid][bought] == 1)
{
      new vehownerid = GetPlayerId(VehicleInfo[vehicleid][vOwner]);
      if(vehownerid != INVALID_PLAYER_ID)
      {
            SendClientMessage(vehownerid, COLOR_RED, "[ERROR] {FFFFFF}Your bought vehicle has been destroyed. You have to buy another one");
            GetPlayerVehicles[VehicleInfo[vehicleid][vOwner]] --;
      }
      fremove(VehicleFile(vehicleid));
      DestroyNeons(vehicleid);
      DestroyVehicle(vehicleid);
}
GetPlayerID returns -1 if no matches found, not INVALID_PLAYER_ID