object, keys use - 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: object, keys use (
/showthread.php?tid=585831)
object, keys use -
Karolukas123 - 16.08.2015
Hey, so i need help.. so how to make random object create in mapp and create on object 3dtext, and if i near that object i can use key_N
Re: object, keys use -
ZToPMaN - 16.08.2015
What is the key " N " do ?
do you want a moveaple objects and createobject?
Re: object, keys use -
Karolukas123 - 16.08.2015
No no no, i need explanation how to make random object on maps.. and if i near object i can use key.. i need how make check if player near that random object
Re: object, keys use -
Banana_Ghost - 17.08.2015
pawn Код:
enum ObjectData
{
ModelID,
Float:oPosX,
Float:oPosY,
Float:oPosZ,
Float:oRotX,
Float:oRotY,
Float:oRotZ
}
static const oInfo[][ObjectData] =
{
{1225, 0.00, 0.00, 0.00, 0.00,0.00, 0.00},
{1226, 0.00, 0.00, 0.00, 0.00,0.00, 0.00}
};
public OnGameModeInit()
{
for(new i = 0; i < sizeof(oInfo); i++)
{
CreateObject(oInfo[i][ModelID],oInfo[i][oPosX],oInfo[i][oPosY],oInfo[i][oPosZ],oInfo[i][oRotX],oInfo[i][oRotY],oInfo[i][oRotZ]);
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_NO)
{
for(new i = 0; i < sizeof(oInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, oInfo[i][oPosX],oInfo[i][oPosY],oInfo[i][oPosZ]))
{
SendClientMessage(playerid, -1, "You are in range of the object.");
break;
}
}
}
return 1;
}
Pretty sure you have your own array to loop through, this is merely an example looping through all of the objects on the server if they press the N key.
EDIT: More into it, you can place object ids and positions into the array above, and have the server create the objects, here they're all being created on gamemode initialization. With the 3D Textlabels, the same logic applies as above.
Re: object, keys use -
Abagail - 17.08.2015
The tricky thing with "random positions" is that there are by default no functions to get singleplayer pedestrian spawn nodes, etc so you need to make the positions manually unless you extract the data into a PAWN format from the game files.