OnPlayerEnterVehicle Error -
MrGtasagamer - 26.08.2015
I made this code inside my script and i got an error:
Code:
PHP код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new string[128];
AttachObjectToVehicle(objectid, vehicleid, 3.525033, -1.234999, -0.251499, 0.000000, 0.000000, 0.000000);
format(string, sizeof(string), "You are entering vehicle %i", 520);
SendClientMessage(playerid, 0xFFFFFFFF, string);
return 1;
}
Error:
PHP код:
error 017: undefined symbol "objectid"
Re: OnPlayerEnterVehicle Error -
Zonoya - 26.08.2015
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.)
Re: OnPlayerEnterVehicle Error -
MrGtasagamer - 26.08.2015
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
Re: OnPlayerEnterVehicle Error -
Zonoya - 26.08.2015
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.
Re: OnPlayerEnterVehicle Error -
MrGtasagamer - 26.08.2015
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.
Re: OnPlayerEnterVehicle Error -
Abagail - 26.08.2015
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.
Re: OnPlayerEnterVehicle Error -
Zonoya - 26.08.2015
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.
Re: OnPlayerEnterVehicle Error -
MrGtasagamer - 26.08.2015
Ok thank you +rep
Re: OnPlayerEnterVehicle Error -
Roberto80 - 26.08.2015
Wait o_o
in the format: format(....:. %i,520);
What!!! Lol if you have the number,just use SendClientMessage!! XD