GTAOnline.net

San Andreas Multiplayer (sa:mp) => Scripting SA-MP [Pawn center] => Discussion démarrée par: ApocKalipsS le 30 Mai 2009, 10:27:17

Titre: TowTruck
Posté par: ApocKalipsS le 30 Mai 2009, 10:27:17
Bonjour,
J'ai un léger problème sur mon script :

if(strcmp(cmd, "/tracter", true) == 0)
{
  if(IsPlayerInAnyVehicle(playerid))
    {
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 525)
        {
new Float:pX,Float:pY,Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
new Float:vX,Float:vY,Float:vZ;
new Found=0;
new Founda=0;
new vid=0;
while((vid<MAX_VEHICLES)&&(!Found))
    {
        vid++;
    GetVehiclePos(vid,vX,vY,vZ);
    if((floatabs(pX-vX)<7.0)&&(floatabs(pY-vY)<7.0)&&(floatabs(pZ-vZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
        {
if(Founda==0)
{
        AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
        Founda=1;
        }
        else if(Founda==1)
            {
            DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
            Founda=0;
            }
        }
      }
if (!Found)
    {
    }
    }
      }
   }

Si je fais /tracter, le véhicule est bien accrocher mais je ne peux pas le détacher si je refais la commande, et si le véhicule tombe, je ne peux pas le reprendre.
Pouvez-vous m'aider ?
Merci de vos réponses.
Titre: Re : TowTruck
Posté par: MadX le 30 Mai 2009, 10:33:39
Je m'y connais pas assez en script pour savoir d'ou viens ton probleme mais tu peut faire une commande /detracter pour detacher la voiture
Titre: Re : TowTruck
Posté par: ApocKalipsS le 30 Mai 2009, 11:15:29
Oui, mais je prefere comme je l'ai fais, en ayant qu'une commande.
Titre: Re : TowTruck
Posté par: S!m le 30 Mai 2009, 17:02:09
Salut,

tu peut tester si le véhicule du joueur a un trailer via la fonction IsTrailerAttachedToVehicle(vehicleid)

++Sim++