[FilterScript] Real Life Vehicle Names
#1

Not sure where to put it, but just think it might be handy.
I took the time to place most of the real life vehicle names into the script.

Pastebin link:

Version 1:
http://pastebin.com/fRUwCuQ8

Version 2:
http://pastebin.com/GeKvTFnz


Example usage:

pawn Код:
new vehicle[24];
GetVehicleName(GetPlayerVehicleID(id), vehicle, sizeof(vehicle));

Example:





70% of all vehicles are done, most just copied from a website and placed them in a script,
Will try to finish it someday.
Reply
#2

Nice
Reply
#3

Switch statement, and don't use format for such a thing lol. It's bad coding practice imho.

pawn Код:
stock GetVehicleName( model ) {
    new szModel[ 32 ];
    switch( model ) {
        case 405: szModel = "1991 BMW 5251";
    }
    return szModel;
}
Nice job anyway
Reply
#4

Nice job
Reply
#5

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Switch statement, and don't use format for such a thing lol. It's bad coding practice imho.

pawn Код:
stock GetVehicleName( model ) {
    new szModel[ 32 ];
    switch( model ) {
        case 405: szModel = "1991 BMW 5251";
    }
    return szModel;
}
Nice job anyway
Also an option, but It's not really a huge problem what I'm doing here.


@ everybody, thanks, It took some time;p
Reply
#6

Quote:
Originally Posted by milanosie
Посмотреть сообщение
Also an option, but It's not really a huge problem what I'm doing here.
It's not efficient. As a scripter you should always choose the most efficient and easy way.
So basically, it's not an option, it's just how you are supposed to do it
Reply
#7

Quote:
Originally Posted by Biesmen
Посмотреть сообщение
It's not efficient. As a scripter you should always choose the most efficient and easy way.
So basically, it's not an option, it's just how you are supposed to do it
And how is it not efficient?
Explain me please,
Reply
#8

Quote:
Originally Posted by milanosie
Посмотреть сообщение
And how is it not efficient?
Explain me please,
Your else-if statement is getting called ~ 200 (depends on the vehicle ID) times when the function is getting used. Is that efficient? No.
The switch statement get called once and checks the value of the given variable in a loop, until it reaches the correct variable.

Format is meant for strings with a dynamic variable in the string. E.g your name
pawn Код:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof name);
format(string, 128,sizeof string, "%s", name)
If you just give the string a different value (I am not sure if I am saying it right in English) without a dynamic variable in the string, you will simply just give it a different value:
pawn Код:
new name[50];
name = "Welcome milanosie!";
SendClientMessage(playerid, 0x000000FF, name);
I'm trying to explain it as simple as possible.
Reply
#9

Quote:
Originally Posted by milanosie
Посмотреть сообщение
And how is it not efficient?
Explain me please,
Switch statements are faster in execution (in this example). Also as mentioned before it's bad coding practice.
Reply
#10

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Switch statement, and don't use format for such a thing lol. It's bad coding practice imho.

pawn Код:
stock GetVehicleName( model ) {
    new szModel[ 32 ];
    switch( model ) {
        case 405: szModel = "1991 BMW 5251";
    }
    return szModel;
}
Nice job anyway
I was going to say the same thing after i saw the code in pastebin. Beside that format usage, it's also slow.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)