SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 26/08/2015, 03:15 PM   #1
MrGtasagamer
Banned
 
Join Date: Mar 2013
Location: Cyprus
Posts: 145
Reputation: 1
Default OnPlayerEnterVehicle Error

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

Code:
PHP Code:
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 Code:
error 017undefined symbol "objectid" 
MrGtasagamer is offline   Reply With Quote
Old 26/08/2015, 03:21 PM   #2
Zonoya
Gangsta
 
Zonoya's Avatar
 
Join Date: Jul 2011
Location: Am I in Rio de Janeiro or the Amazon, you tell me?
Posts: 664
Reputation: 19
Default Re: OnPlayerEnterVehicle Error

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.)
__________________
Code:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) //If the password was incorrect
    {
        printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
        {
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
            {
                SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!"); //Send a message
                Ban(i); //They are now banned.
            }
        }
    }
    return 1;
}
Zonoya is offline   Reply With Quote
Old 26/08/2015, 03:24 PM   #3
MrGtasagamer
Banned
 
Join Date: Mar 2013
Location: Cyprus
Posts: 145
Reputation: 1
Default Re: OnPlayerEnterVehicle Error

Quote:
Originally Posted by Zonoya View Post
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
MrGtasagamer is offline   Reply With Quote
Old 26/08/2015, 03:27 PM   #4
Zonoya
Gangsta
 
Zonoya's Avatar
 
Join Date: Jul 2011
Location: Am I in Rio de Janeiro or the Amazon, you tell me?
Posts: 664
Reputation: 19
Default Re: OnPlayerEnterVehicle Error

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.
__________________
Code:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) //If the password was incorrect
    {
        printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
        {
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
            {
                SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!"); //Send a message
                Ban(i); //They are now banned.
            }
        }
    }
    return 1;
}
Zonoya is offline   Reply With Quote
Old 26/08/2015, 03:31 PM   #5
MrGtasagamer
Banned
 
Join Date: Mar 2013
Location: Cyprus
Posts: 145
Reputation: 1
Default Re: OnPlayerEnterVehicle Error

Quote:
Originally Posted by Zonoya View Post
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.
MrGtasagamer is offline   Reply With Quote
Old 26/08/2015, 03:33 PM   #6
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,133
Reputation: 445
Default Re: OnPlayerEnterVehicle Error

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.
Abagail is offline   Reply With Quote
Old 26/08/2015, 03:36 PM   #7
Zonoya
Gangsta
 
Zonoya's Avatar
 
Join Date: Jul 2011
Location: Am I in Rio de Janeiro or the Amazon, you tell me?
Posts: 664
Reputation: 19
Default Re: OnPlayerEnterVehicle Error

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.
__________________
Code:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) //If the password was incorrect
    {
        printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
        {
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
            {
                SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!"); //Send a message
                Ban(i); //They are now banned.
            }
        }
    }
    return 1;
}
Zonoya is offline   Reply With Quote
Old 26/08/2015, 03:36 PM   #8
MrGtasagamer
Banned
 
Join Date: Mar 2013
Location: Cyprus
Posts: 145
Reputation: 1
Default Re: OnPlayerEnterVehicle Error

Ok thank you +rep
MrGtasagamer is offline   Reply With Quote
Old 26/08/2015, 05:43 PM   #9
Roberto80
Huge Clucker
 
Join Date: Dec 2014
Posts: 255
Reputation: 20
Default Re: OnPlayerEnterVehicle Error

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OnPlayerEnterVehicle bug Alpay0098 Scripting Help 10 20/05/2015 03:58 PM
OnPlayerEnterVehicle hillko Scripting Help 2 21/04/2014 12:00 PM
OnPlayerEnterVehicle CrazyChoco Scripting Help 10 30/08/2012 07:23 PM
onplayerentervehicle Pooh7 Help Archive 3 27/12/2010 11:49 AM
Help | OnPlayerEnterVehicle Daniel13145 Help Archive 3 09/02/2010 12:27 PM


All times are GMT. The time now is 02:24 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.