SA-MP Forums Archive
RemovePlayerAttachedObject Help - 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: RemovePlayerAttachedObject Help (/showthread.php?tid=464524)



RemovePlayerAttachedObject Help - Drago987 - 17.09.2013

I have A Problem with RemovePlayerAttachedObject for cmd seatbelt ,when player on bike and do /sb he puts on his helmet and Attaches the motorcycle Helmet and he need to do /sb again to remove it ,can you make it that as soon as the player gets off the bike The Helmet Removes Automatically and he doesnt need to do /sb ?

here is the RemovePlayerAttachedObject
pawn Код:
else if(IsPlayerInAnyVehicle(playerid) == 1 && Seatbelt[playerid] == 1)
    {
        Seatbelt[playerid] = 0;
        if(IsABike(GetPlayerVehicleID(playerid)))
        {
            format(string, sizeof(string), "* %s reaches for their helmet, and takes it off.", GetPlayerNameEx(playerid));
            RemovePlayerAttachedObject(playerid, 1);
            SendClientMessageEx(playerid, COLOR_WHITE, "You have taken off your helmet.");
        }
and the whole command
pawn Код:
CMD:sb(playerid, params[]) return cmd_seatbelt(playerid, params);

CMD:seatbelt(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid) == 0)
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You are not in a vehicle!");
        return 1;
    }
    new string[50 + MAX_PLAYER_NAME];
    if(IsPlayerInAnyVehicle(playerid) == 1 && Seatbelt[playerid] == 0)
    {
        Seatbelt[playerid] = 1;
        if(IsABike(GetPlayerVehicleID(playerid)))
        {
            format(string, sizeof(string), "* %s reaches for their helmet, and puts it on.", GetPlayerNameEx(playerid));
            SetPlayerAttachedObject(playerid, 1, 18645, 2, 0.107, 0.020, 0.0, 90, 90, 0);
            SendClientMessageEx(playerid, COLOR_WHITE, "You have put on your helmet.");
        }
        else
        {
            format(string, sizeof(string), "* %s reaches for their seatbelt, and buckles it up.", GetPlayerNameEx(playerid));
            SendClientMessageEx(playerid, COLOR_WHITE, "You have put on your seatbelt.");
        }

    }
    else if(IsPlayerInAnyVehicle(playerid) == 1 && Seatbelt[playerid] == 1)
    {
        Seatbelt[playerid] = 0;
        if(IsABike(GetPlayerVehicleID(playerid)))
        {
            format(string, sizeof(string), "* %s reaches for their helmet, and takes it off.", GetPlayerNameEx(playerid));
            RemovePlayerAttachedObject(playerid, 1);
            SendClientMessageEx(playerid, COLOR_WHITE, "You have taken off your helmet.");
        }
        else
        {
            format(string, sizeof(string), "* %s reaches for their seatbelt, and unbuckles it.", GetPlayerNameEx(playerid));
            SendClientMessageEx(playerid, COLOR_WHITE, "You have taken off your seatbelt.");
        }
    }
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    return 1;
}



Re: RemovePlayerAttachedObject Help - EiresJason - 17.09.2013

Is this what you're looking for?

Put this code:
pawn Код:
if(IsPlayerInAnyVehicle(playerid) == 1 && Seatbelt[playerid] == 1)
    {
        Seatbelt[playerid] = 0;
        RemovePlayerAttachedObject(targetid, 1);
        if(IsABike(GetPlayerVehicleID(playerid)))
        {
            format(string, sizeof(string), "* %s reaches for their helmet, and takes it off.", GetPlayerNameEx(playerid));
            RemovePlayerAttachedObject(playerid, 1);
            SendClientMessageEx(playerid, COLOR_WHITE, "You have taken off your helmet.");
        }
        else
        {
            format(string, sizeof(string), "* %s reaches for their seatbelt, and unbuckles it.", GetPlayerNameEx(playerid));
            SendClientMessageEx(playerid, COLOR_WHITE, "You have taken off your seatbelt.");
        }
    }
Under
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{

  //put it here.
   return 1;
}



Re: RemovePlayerAttachedObject Help - Drago987 - 17.09.2013

Yea ,Thanks alot Mate


Re: RemovePlayerAttachedObject Help - EiresJason - 17.09.2013

Np