SetObjectPos - Crash server?
#1

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 ?
Reply
#2

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

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

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

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)
Reply
#5

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?);
Reply
#6

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) */
Reply
#7

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
Reply
#8

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

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 ?
Reply
#10

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

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


Forum Jump:


Users browsing this thread: