[snippet] GetVehicleNameFromCustomModel

Started by MacTavish, Jul 15, 2015, 09:54 AM

Previous topic - Next topic

MacTavish

As you see that many peoples are asking about it and they are unable to create such system so i created this snippet

Just put this in your Functions.nut

function GetVehicleNameFromCustomModel(model)
{
switch(model)
{
case 6400: return "Your first car name";
case 6401: return "Your sec car name";
// you can create more like this and then
default: return "Name not specified";
}
}


Now an example of using this

onPlayerEnterVehicle(player, vehicle, door)
{
if (GetVehicleNameFromModel(vehicle.Model)== null ) MessagePlayer("Entered in "+GetVehicleNameFromCustomModel(vehicle.Model)+"",player); // lets check if the squirrel function return name as null if yes then our function will send vehicle name from its record
else MessagePlayer("Entered In "+GetVehicleNameFromModel(vehicle.Model)+"",player); // else if the name isnt null then it will send name of vehicle from module
}

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

[VSS]Shawn

I Was the one who Really in need of that Thanks

But Check out your code Getvehiclenamefromcustommodel but in entervehicle there is getvehiclenamefrommodel

MacTavish


Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Thijn

Why not add the GetVehicleNameFromModel function to the default switch? In that case you can just use one function call everywhere, instead of the messy code you gave as an example.

MacTavish

Quote from: Thijn on Jul 15, 2015, 04:18 PMWhy not add the GetVehicleNameFromModel function to the default switch? In that case you can just use one function call everywhere, instead of the messy code you gave as an example.

Because if they add more new custom vehicles and didnt listed the i'd in function then it will return null

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Thijn

Quote from: Beztone on Jul 19, 2015, 08:22 PM
Quote from: Thijn on Jul 15, 2015, 04:18 PMWhy not add the GetVehicleNameFromModel function to the default switch? In that case you can just use one function call everywhere, instead of the messy code you gave as an example.

Because if they add more new custom vehicles and didnt listed the i'd in function then it will return null
I guess I'm done trying, you're too stubborn to learn.

MacTavish

Hey i'll try my best to improve it :) i will create an function to use everywhere but if you have an better idea then tell me i don't mind and i'd love to learn i am not like others e.g Finch ;D

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

KAKAN

Thijin why don't u make this topic sticky?
oh no

.

.

KAKAN

BECAZ This is gonna help people who are using custom vehicles for the 1st time
oh no

.

Quote from: KAKAN on Jul 26, 2015, 06:02 AMBECAZ This is gonna help people who are using custom vehicles for the 1st time

And? Is it that hard to come up with, as a solution?
.

KAKAN

oh no

.

Quote from: KAKAN on Jul 26, 2015, 06:10 AMWhat u mean?

I don't know that either. But here's what I didn't meant:

  • Jump from a flying plane without a parachute.
  • Tie a huge rock to your leg and jump in the sea.
  • Light up a dynamite in your a$$.
  • Jump into a live volcano.
  • Throw gasoline on you and light it on fire.
  • Enter a cage of wild lions.
  • Tie your self to a submersing submarine.
  • Stand in front of a moving train with no breaks.
  • Stay bellow a rocket that's being launched.
  • ...
.

Thijn

Locked. The script has been posted, no additional comments add anything useful to this topic.
(And no, I'm not going to sticky this. If you can't come up with this script yourself, you should start to learn how to search)