Is there a way - rep ++ question -
buburuzu19 - 15.12.2014
Is there a way to destroy a trailer or do something when the trailer deataches from truck ?
Thanks,
buburuzu19.
Re: Is there a way - rep ++ question -
Kruno88 - 15.12.2014
There isn't.
Re: Is there a way - rep ++ question -
Raweresh - 15.12.2014
I think you can work with that callback:
https://sampwiki.blast.hk/wiki/OnTrailerUpdate
And this function:
https://sampwiki.blast.hk/wiki/IsTrailerAttachedToVehicle
Re: Is there a way - rep ++ question -
buburuzu19 - 15.12.2014
But if i make a global timer , how to check if trailer is not attached to any truck , the trailer is created by addstaticvehicleex , because my cars are created in Mysql db and the trailers are created when a player selects a route.
Re: Is there a way - rep ++ question -
Abagail - 15.12.2014
pawn Код:
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;
}
Then you can:
pawn Код:
public OnTrailerDetach(playerid, vehicleid, trailer)
{
DestroyVehicle(trailer);
return 1;
}
Re: Is there a way - rep ++ question -
Raweresh - 15.12.2014
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;
}
Re: Is there a way - rep ++ question -
buburuzu19 - 16.12.2014
Quote:
Originally Posted by Abagail
pawn Код:
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; }
Then you can:
pawn Код:
public OnTrailerDetach(playerid, vehicleid, trailer) { DestroyVehicle(trailer); return 1; }
|
Nothing happens ...
Re: Is there a way - rep ++ question -
buburuzu19 - 16.12.2014
Quote:
Originally Posted by Raweresh
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;
}
|
I get some erros, first i get assumed 0 cuz () i put them to [] and now i have:
pawn Код:
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;
}
And errors :
pawn Код:
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
Re: Is there a way - rep ++ question -
Raweresh - 16.12.2014
Why you change ( to [?
Okay, use my version but you need SAMP 0.3z R4 version, here is windows pack:
http://files.sa-mp.com/samp03z_svr_R4_win32.zip
Re: Is there a way - rep ++ question -
buburuzu19 - 16.12.2014
0.3z R4 on linux i have ..my server is hosted
EDIT: So how to fix ur code?