help +rep
#1

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
Reply
#2

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

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
Reply
#4

the enum for VehicleInfo please.
Reply
#5

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
}
Reply
#6

Why don't you use killerid parameter in OnVehicleDeath?
Reply
#7

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

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);
}
Reply
#9

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.
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)