Car Variable question
#1

Hello guys, please what function of variable i should use for car? For example I make variable new MyCar[WHATHERE?] what I need to type? Thanks, I want to define one car here for job.
Reply
#2

I don't want to copy paste things all over the place so read my post here, which should explain you how to create vehicle variables.

http://forum.sa-mp.com/showpost.php?...59&postcount=3
Reply
#3

Thx mate, after I add my Police Bullet to faction vehicles can I use this?

pawn Код:
COMMAND:policelights(playerid, cmdtext[])
{
    if(!IsValidObject(VehicleObject[0]))
    {
        VehicleObject[0] = CreateObject(18646,0,0,-1000,0,0,0,100);
        AttachObjectToVehicle(VehicleObject[0], STU1, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000000);
        SendClientMessage(playerid, 0xFFFFFF, You turned on police light on your car!"
    }

    else

    if(IsValidObject(VehicleObject[0]))
    {
        DestroyObject(VehicleObject[0]);
        SendClientMessage(playerid, 0xFFFFFF, You turned off police light on your car!"

    }
   
    return 1;
}
This thing add the police light for Bullet vehicle.
Reply
#4

Quote:
Originally Posted by Riwerry
Посмотреть сообщение
Thx mate, after I add my Police Bullet to faction vehicles can I use this?

pawn Код:
COMMAND:policelights(playerid, cmdtext[])
{
    if(!IsValidObject(VehicleObject[0]))
    {
        VehicleObject[0] = CreateObject(18646,0,0,-1000,0,0,0,100);
        AttachObjectToVehicle(VehicleObject[0], STU1, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000000);
        SendClientMessage(playerid, 0xFFFFFF, "You turned on police light on your car!");
    }

    else

    if(IsValidObject(VehicleObject[0]))
    {
        DestroyObject(VehicleObject[0]);
        SendClientMessage(playerid, 0xFFFFFF, "You turned off police light on your car!");
    }
   
    return 1;
}
This thing add the police light for Bullet vehicle.
Of course, it shouldn't give you any issues. Also make sure that you write SendClientMessage() correctly because you wrote it wrong a few times, you didn't close the parenthesis and the compiler will give you errors if you don't do that. But I fixed some of them for you.

Correct way:
pawn Код:
SendClientMessage(playerid, 0xFFFFFF, "You turned off police light on your car!");
Incorrect way:
pawn Код:
SendClientMessage(playerid, 0xFFFFFF, You turned off police light on your car!"
Reply
#5

Ehm, and when I'll finish my faction vehicle, what vehicle ID i type here? (Becouse i want police light only on this Police Bullet, so I need to type here some variable, that's what I need)

AttachObjectToVehicle(VehicleObject[0], HEREMUSTBEVARIABLE, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000 000);
Reply
#6

Quote:
Originally Posted by Riwerry
Посмотреть сообщение
Ehm, and when I'll finish my faction vehicle, what vehicle ID i type here? (Becouse i want police light only on this Police Bullet, so I need to type here some variable, that's what I need)

AttachObjectToVehicle(VehicleObject[0], HEREMUSTBEVARIABLE, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000 000);
Here's the documentation on AttachObjectToVehicle:

https://sampwiki.blast.hk/wiki/AttachObjectToVehicle

"HEREMUSTBEVARIABLE" is the vehicleid which you can get by using new carid = GetPlayerVehicleID(playerid); or by grabbing it from somewhere else. The vehicleid is a number.
Reply
#7

Yeah mate, thanks a lot! And my last question, when i want to create more vehicles, what will be using these police lights, BUT on same COMMAND (/policelights), for example i actually have Bullet maked correctly and how i need to script the second vehicle? For example Sultan? I just don't know how to add second vehicle to this same command.

pawn Код:
//Current command
COMMAND:policelights(playerid, cmdtext[])
{
    if(IsPlayerInVehicle(playerid, STU1))
    if(!IsValidObject(VehicleObject[0]))
    {
        VehicleObject[0] = CreateObject(18646,0,0,-1000,0,0,0,100);
        AttachObjectToVehicle(VehicleObject[0], STU1, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000000);
        SendClientMessage(playerid, 0xFFFFFF, "You turned on police light on your car!");
    }

    else

    if(IsPlayerInVehicle(playerid, STU1))
    if(IsValidObject(VehicleObject[0]))
    {
        DestroyObject(VehicleObject[0]);
        SendClientMessage(playerid, 0xFFFFFF, "You turned off police light on your car!");
    }
   
    return 1;
}
Please, help me with that
Reply
#8

Untested. Make a variable for STU2, STU2 is the other car.

pawn Код:
COMMAND:policelights(playerid, cmdtext[])
{
    if(!IsValidObject(VehicleObject[0]) && IsPlayerInVehicle(playerid, STU1 && STU2))
    {
        VehicleObject[0] = CreateObject(18646,0,0,-1000,0,0,0,100);
        AttachObjectToVehicle(VehicleObject[0], STU1, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000000);
        SendClientMessage(playerid, 0xFFFFFF, "You turned on police light on your car!");
    }
    else if(!IsValidObject(VehicleObject[0]) && IsPlayerInVehicle(playerid, STU1 && STU2))
    {
        DestroyObject(VehicleObject[0]);
        SendClientMessage(playerid, 0xFFFFFF, "You turned off police light on your car!");
    }
    return 1;
}
Reply
#9

Thx mate gonna try it..

//Edit Is possible to add second car vehicle ID here? Cuz here is only one car STU1
pawn Код:
AttachObjectToVehicle(VehicleObject[0], STU1, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000000);
//EDIT 2: Got an errors in this line if(!IsValidObject(VehicleObject[0])) && IsPlayerInVehicle(playerid, STU1 && STU2))

C:\Users\Jakub\Desktop\Server\gamemodes\LVRP.pwn(3 6 : error 029: invalid expression, assumed zero
C:\Users\Jakub\Desktop\Server\gamemodes\LVRP.pwn(3 6 : error 001: expected token: ";", but found ")"
C:\Users\Jakub\Desktop\Server\gamemodes\LVRP.pwn(3 6 : error 029: invalid expression, assumed zero
C:\Users\Jakub\Desktop\Server\gamemodes\LVRP.pwn(3 6 : fatal error 107: too many error messages on one line
Reply
#10

Okay, don't worry i'll make other topic with help to this problem, becouse I got answer for this topic
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)