SA-MP Forums Archive
SetObjectPos - Crash server? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SetObjectPos - Crash server? (/showthread.php?tid=65549)



SetObjectPos - Crash server? - KennethHoegh - 13.02.2009

Hello.

I have a problem whit my SA:MP server - im a new scripter and will try to place a gate.
But when i use SetObjectPos to set my object sе

Код:
public OnGameModeInit()
{
  SetObjectPos(971,1780.2560,-1896.2129,13.3895);
  	return 1;
}
Then my server cannot start - if i remove it the server starts fine?
What is the problem ?


Re: SetObjectPos - Crash server? - Double-O-Seven - 13.02.2009

Firstly: You are using the model ID as object ID.
Secondly: You haven't created any objects.


Re: SetObjectPos - Crash server? - pspleo - 13.02.2009

Youre doing modelid instead of objectid.
Gotta assign an objectid to an variable.

pawn Код:
new object;
object = CreateObject(971, ...);
SetObjectPos(object, ...);



Re: SetObjectPos - Crash server? - KennethHoegh - 13.02.2009

Quote:
Originally Posted by [MG3
Double-O-Seven ]
Firstly: You are using the model ID as object ID.
Secondly: You haven't created any objects.
1. I used the ID i found here? Isent that the ID i should use? https://sampwiki.blast.hk/wiki/Game_Object_ID_List

2. Should i use CreateObject then ? Or what (The gate should be abel to move by using a command)


Re: SetObjectPos - Crash server? - KennethHoegh - 13.02.2009

Quote:
Originally Posted by [K4L
Leopard ]
Youre doing modelid instead of objectid.
Gotta assign an objectid to an variable.

pawn Код:
new object;
object = CreateObject(971, ...);
SetObjectPos(object, ...);
pawn Код:
new object;
object = CreateObject(971,COORDS here?);
SetObjectPos(object or 971?,COORDS here?);



Re: SetObjectPos - Crash server? - Yaheli_Faro - 13.02.2009

Quote:
Originally Posted by KennethHoegh
1. I used the ID i found here? Isent that the ID i should use? https://sampwiki.blast.hk/wiki/Game_Object_ID_List
That is the model ID which is used only in CreateObject.

You need to assign the object to a variable in order have the ID easily available.
Here is what you need to do:

At the top (or near, as long as it's outside of any callbacks) put:
pawn Код:
new myobj; /* If you are only going to move it in OnGamemodeInit then put it in OnGamemodeInit... */
Then, in OnGameModeInit do this:
pawn Код:
myobj = CreateObject(971, params); /* replace 'params' with all the coords and angles needed. */
SetObjectPos(myobj, 0.0, 0.0, 5.0); /* This will move move the object you created (myobj) and set it's position to 0.0 (X), 0.0(Y) and 5.0(Z) */



Re: SetObjectPos - Crash server? - KennethHoegh - 13.02.2009

Quote:
Originally Posted by Yaheli
Quote:
Originally Posted by KennethHoegh
1. I used the ID i found here? Isent that the ID i should use? https://sampwiki.blast.hk/wiki/Game_Object_ID_List
Then, in OnGameModeInit do this:
pawn Код:
myobj = CreateObject(971, params); /* replace 'params' with all the coords and angles needed. */
SetObjectPos(myobj, 0.0, 0.0, 5.0); /* This will move move the object you created (myobj) and set it's position to 0.0 (X), 0.0(Y) and 5.0(Z) */
SetObjectPos is moving it so it is another place - it should move when i type /opengate LSPD as an exampel


Re: SetObjectPos - Crash server? - Yaheli_Faro - 13.02.2009

Ok then just put under the command '/lsgate' your SetObjectPos function.


Re: SetObjectPos - Crash server? - KennethHoegh - 13.02.2009

Quote:
Originally Posted by Yaheli
Ok then just put under the command '/lsgate' your SetObjectPos function.
As i say i am a new scripter - can you mabey show me a code where it showed ?


Re: SetObjectPos - Crash server? - Daren_Jacobson - 13.02.2009

also you may want to use MoveObject, which makes the object move slowly down.


Re: SetObjectPos - Crash server? - KennethHoegh - 13.02.2009

Quote:
Originally Posted by Daren_Jacobson
also you may want to use MoveObject, which makes the object move slowly down.
Check you messages..