[Include] GetVehicleName - Simple, Easy & Efficient function.
#1

- Function:

pawn Code:
native GetVehicleName(vehicleid)
- Example:

pawn Code:
#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <GVN>

CMD:car(playerid, params[])
{
    new modelid, string[75];
    if(sscanf(params, "i", modelid)) return SendClientMessage(playerid, -1, "{FF0000}TYPE: {FFFFFF}/Car [Model ID]");
    if(modelid < 400 || modelid > 611) return SendClientMessage(playerid, -1, "Invalid vehicle id.");
    format(string, sizeof(string), "VEH ID: %d it's %s.", modelid, GetVehicleName(modelid));
    SendClientMessage(playerid, -1, string);
    return 1;
}
- Including:

pawn Code:
#include <a_samp>
#include <GVN>
#include <others_includes>
- Download:

- Solidfiles.
- Pastebin.
Reply
#2

An array with the names is better.
Reply
#3

Nice job but this function can post on Useful Functions Topic !

anyway good job !
Reply
#4

"new vehname[1500];"
oh god.

18 is enough.
Reply
#5

This isn't really for an include, it's for useful snippets of code.
But, nice work I guess.
Reply
#6

zcmd and sscanf, i dont see any implementation of those includes.
Using array for this purpose is completly efficient. I dont know why would anyone call this efficient.

You havent made any checks either if the vehicle is valid!

In your example, the syntax says, /car [veh ID]. Then why would you limit the usage for vehicle id b/w 400 - 611! It must be modelid. As well for the function.
OR you must use something like this:
pawn Code:
stock GetVehicleName(vehicleid)
{
       new name[18];
       switch(GetVehicleModel(vehicleid))
       {
....
Reply
#7

Quote:
Originally Posted by Ralfie
View Post
An array with the names is better.
Thanks anyway.

Quote:
Originally Posted by M4D
View Post
Nice job but this function can post on Useful Functions Topic !

anyway good job !
Thanks.

Quote:
Originally Posted by Kyance
View Post
"new vehname[1500];"
oh god.

18 is enough.
Lol, edited.

Quote:
Originally Posted by dominik523
View Post
This isn't really for an include, it's for useful snippets of code.
But, nice work I guess.
Thanks.

Quote:
Originally Posted by Gammix
View Post
zcmd and sscanf, i dont see any implementation of those includes.
Using array for this purpose is completly efficient. I dont know why would anyone call this efficient.

You havent made any checks either if the vehicle is valid!

In your example, the syntax says, /car [veh ID]. Then why would you limit the usage for vehicle id b/w 400 - 611! It must be modelid. As well for the function.
OR you must use something like this:
pawn Code:
stock GetVehicleName(vehicleid)
{
       new name[18];
       switch(GetVehicleModel(vehicleid))
       {
....
Still example script and this include works fine and faster.

EDIT: Now I understood what are you talking about zcmd & sscanf.
I tested that filterscript, so I needed zcmd & sscanf to create an example command.
Pastebin & Solidfiles link has been re-uploaded.
Thanks!
Reply
#8

EDIT: the param vehicleid must be modelid.

I think rest is solved.
Reply
#9

Arrays would be faster here.

If you wish to keep the switch, then add a default where you must return "NONE" or something similar.
Reply
#10

Good Work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)