SA-MP Forums Archive
How i can create pickup infront of player - 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: How i can create pickup infront of player (/showthread.php?tid=604220)



How i can create pickup infront of player - SmileyForCheat - 02.04.2016

Код:
COMMAND:pickup(playerid, params[])
{
	new szString[128];
	if(sscanf(params, "d", pickupids)) return SendClientMessage(playerid, COLOR_RED, "You have to insert the pickup id.");
	new Float:X, Float:Y, Float:Z, Float:Angle;
	GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
	pickup = CreatePickup(pickupids, 2, Float:X, Float:Y, Float:Z, GetPlayerVirtualWorld(playerid));
	return 1;
}
how to make the pickup infront of player?
I already add Float:Y+2 but when I'm facing to south it spawn on my back


Re: How i can create pickup infront of player - colonel-top - 02.04.2016

You could try this stock function
Cr.Forum https://sampforum.blast.hk/showthread.php?tid=344951
Cr.******
pawn Код:
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    // Created by ******

    new Float:a;

    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);

    if (GetPlayerVehicleID(playerid)) {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }

    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}



Re: How i can create pickup infront of player - SmileyForCheat - 02.04.2016

Quote:
Originally Posted by colonel-top
Посмотреть сообщение
You could try this stock function
Cr.Forum https://sampforum.blast.hk/showthread.php?tid=344951
Cr.******
pawn Код:
stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
    // Created by ******

    new Float:a;

    GetPlayerPos(playerid, x, y, a);
    GetPlayerFacingAngle(playerid, a);

    if (GetPlayerVehicleID(playerid)) {
        GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }

    x += (distance * floatsin(-a, degrees));
    y += (distance * floatcos(-a, degrees));
}
Thanks