OnPlayerEnterVehicle Error
#1

I made this code inside my script and i got an error:

Code:
PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    new 
string[128];
    
AttachObjectToVehicle(objectidvehicleid3.525033, -1.234999, -0.2514990.0000000.0000000.000000);
    
format(stringsizeof(string), "You are entering vehicle %i"520);
    
SendClientMessage(playerid0xFFFFFFFFstring);
    return 
1;

Error:
PHP код:
error 017undefined symbol "objectid" 
Reply
#2

You're trying to attach the object 'objectid', which isn't part of the OnPlayerEnterVehicle public call, you'd do something like:

new Object = CreateObject(bla bla bla)

And then under OnPlayerEnterVehicle
AttachObjectToVehicle(Object, vehicleid, bla bla bla)

Of course, just a basis, it's going to vary depending on what you're doing, I don't get what you're doing. You're just calling an objectid variable that's part of the syntax of the function, nothing more.

(I believe that's what's wrong, at least. Someone with more experience can always correct me, if I have gotten a detail wrong above, though.)
Reply
#3

Quote:
Originally Posted by Zonoya
Посмотреть сообщение
You're trying to attach the object 'objectid', which isn't part of the OnPlayerEnterVehicle public call, you'd do something like:

new Object = CreateObject(bla bla bla)

And then under OnPlayerEnterVehicle
AttachObjectToVehicle(Object, vehicleid, bla bla bla)

Of course, just a basis, it's going to vary depending on what you're doing, I don't get what you're doing. You're just calling an objectid variable that's part of the syntax of the function, nothing more.

(I believe that's what's wrong, at least. Someone with more experience can always correct me, if I have gotten a detail wrong above, though.)
can you make it so I will know in future how it looks like?
thx
Reply
#4

I can't, really, since I don't know what you're trying to do, you need to create an object to go on that vehicle, and then use the attach option to attach it, only you can really do it since I really don't have any clue what youu're trying to accomplish with this.
Reply
#5

Quote:
Originally Posted by Zonoya
Посмотреть сообщение
I can't, really, since I don't know what you're trying to do, you need to create an object to go on that vehicle, and then use the attach option to attach it, only you can really do it since I really don't have any clue what youu're trying to accomplish with this.
Well i wanted to create a flag object which go's on the wing of the hydra when a players enters it.
Reply
#6

First of all,
OnPlayerEnterVehicle is a bad place to put this, this is called when they (attempt) to enter a vehicle, even if locked & or something else happens that prevents them from doing so(such as being killed, being teleported, etc).

OnPlayerStateChange would be a better callback for this, though you should store a variable aswell holding the objectID so you can detect if it's already been added and in future callbacks such as OnVehicleDeath destroy it.

You need to use CreateObject to create the initial object.
Reply
#7

Well, the flag ID is 2914, all you'd do really is:

new Flag[MAX_PLAYERS]; or something if you're doing one flag for each player in a hydra, you'd put that at the top of your script. If not, just skip that bit, and put: new Flag; in the OnPlayerEnterVehicle Callback.

After that, you create the object and assign it to the flag variable, with: Flag (Optionally Flag[playerid]) = CreateObject(2914, All the other things needed);

And then AttachObject(Flag, vehicleid, everything else);

That's how I think it'd go.

As the person above said though, OnPlayerEnterVehicle is a bad place to be doing this. Also, with your current code, it'll try adding the flag to every vehicle the player enters.
Reply
#8

Ok thank you +rep
Reply
#9

Wait o_o
in the format: format(....:. %i,520);
What!!! Lol if you have the number,just use SendClientMessage!! XD
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)