SetVehiclePosition +1 of player location - 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: SetVehiclePosition +1 of player location (
/showthread.php?tid=418746)
SetVehiclePosition +1 of player location -
Private200 - 25.02.2013
pawn Код:
#define COLOR_RED 0xF04747FF
CMD:getvehicle(playerid, params[])
{
// Check if the player's admin-level is at least 1
if (APlayerData[playerid][PlayerLevel] >= 1)
{
new vehicleid;
if(sscanf(params, "i", vehicleid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /getvehicle [vehicleid]");
if(GetVehicleModel(vehicleid) == 0 || vehicleid >= MAX_VEHICLES) return SendClientMessage(playerid, COLOR_RED, "That vehicle does not exist.");
new Float:playerPos[3];
GetPlayerPos(playerid, playerPos[0], playerPos[1], playerPos[2]);
GetXYInFrontOfPlayer(playerid, playerPos[0], playerPos[1], 5.0);
SetVehiclePos(vehicleid, playerPos[0], playerPos[1], playerPos[2]);
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
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));
}
I was lazy to create my own, so I found this out, but I can't configure where to add the +1, so the car spawns 1 feet up the ground or the same place with me. Can someone help me on this?
Thanks.
Re: SetVehiclePosition +1 of player location -
tyler12 - 25.02.2013
SetVehiclePos(vehicleid, playerPos[0]+1, playerPos[1]+1, playerPos[2]);
Re: SetVehiclePosition +1 of player location -
Jeffry - 25.02.2013
pawn Код:
SetVehiclePos(vehicleid, playerPos[0], playerPos[1], playerPos[2]+1);
//playerid, x, y, z => z = height, we make z+1 => one feet higher from the ground