15.12.2014, 17:51
Is there a way to destroy a trailer or do something when the trailer deataches from truck ?
Thanks,
buburuzu19.
Thanks,
buburuzu19.
public OnTrailerUpdate(playerid, vehicleid)
{
Trailer[vehicleid] = GetVehicleTrailer(vehicleid);
return 1;
}
public OnPlayerUpdate(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid) && !IsTrailerAttachedToVehicle(vehicleid))
{
if(Trailer[vehicleid] != INVALID_PLAYER_ID)
{
CallLocalFunction("OnTrailerDetach", "id", playerid, vehicleid, Trailer[vehicleid]);
Trailer[vehicleid] = INVALID_VEHICLE_ID;
return true;
}
}
return true;
}
public OnTrailerDetach(playerid, vehicleid, trailer)
{
DestroyVehicle(trailer);
return 1;
}
public OnTrailerUpdate(playerid, vehicleid) { for(new x, y = MAX_VEHICLES; x < y; x++) { if(IsTrailerAttachedToVehicle(x) && GetVehicleTrailer(x) == vehicleid)) { //trailer is attached return 1; } } //trailer not attached return 1; }
pawn Код:
pawn Код:
|
I think I have better way to do it:
Код:
public OnTrailerUpdate(playerid, vehicleid) { for(new x, y = MAX_VEHICLES; x < y; x++) { if(IsTrailerAttachedToVehicle(x) && GetVehicleTrailer(x) == vehicleid)) { //trailer is attached return 1; } } //trailer not attached return 1; } |
forward OnTrailerUpdate(playerid, vehicleid);
public OnTrailerUpdate(playerid, vehicleid)
{
for(new x, y = MAX_VEHICLES; x < y; x++)
{
if(IsTrailerAttachedToVehicle[x] && GetVehicleTrailer[x] == vehicleid))
{
return 1;
}
}
DestroyVehicle(trucker[playerid]);
return 1;
}
C: x(2328) : error 028: invalid subscript (not an array or too many subscripts): "IsTrailerAttachedToVehicle"
C: x(2328) : warning 215: expression has no effect
C: x(2328) : error 001: expected token: ";", but found "]"
C: x(2328) : error 029: invalid expression, assumed zero
C: x(2328) : fatal error 107: too many error messages on one line