Spawn object... - 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: Spawn object... (
/showthread.php?tid=308125)
Spawn object... -
Gooday - 02.01.2012
This code spawn the opject "over the head" of the player,
pawn Код:
case 5:
{
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
if(atblock[playerid] < MAX_ROADBLOCKS)
{
block[atrb][playerid] = CreateObject(18728, X, Y, Z-0.2, A, 150);
GameTextForPlayer(playerid,"~w~Flare ~b~Created!",3000,1);
#if SEND == true
GetPlayerName(playerid,pName,32);
format(string,sizeof string," %s added a roadblock(%i).",pName,number);
SendClientMessageToAll(COLOR_GREEN, string);
#else
SetTimerEx("ExpireRoadblock", EXPIRE_MINUTES*60000, false, "i", block[atrb][playerid]);
atblock[playerid] += 1;
#endif
} else {
format(string,sizeof string,"You cannot place more then %i Roadblocks!",MAX_ROADBLOCKS);
SendClientMessage(playerid, COLOR_RED, string);
}
return 1;
}
How i can spawn the object under the foot? (i mean spawn at ground level the object)
Re: Spawn object... -
Babul - 02.01.2012
the z axis (facing up/down), raises in value when going up. so you want to lower the opbject down by, lets say, 1.6 units - thats a subtraction of 1.6 on the z-pos parameter:
Код:
block[atrb][playerid] = CreateObject(18728, X, Y, Z-0.2-1.6, A, 150);
or to make it simpler (it doesnt make AN difference when you are using constant values whcih gets added at the precompile process, so keep it like this fr better readability):
Код:
block[atrb][playerid] = CreateObject(18728, X, Y, Z-1.8, A, 150);
if you want the block spawn in front of the player at the ground, you will need to transform the x/y position with the sinus/cosinus and the facing angle.