GetVehicleName - Simple, Easy & Efficient function. -
HY - 08.03.2015
- 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.
Re: GetVehicleName - Simple, Easy & Efficient function. -
Evocator - 08.03.2015
An array with the names is better.
Re: GetVehicleName - Simple, Easy & Efficient function. -
M4D - 08.03.2015
Nice job but this function can post on
Useful Functions Topic !
anyway good job !
Re: GetVehicleName - Simple, Easy & Efficient function. -
Kyance - 08.03.2015
"new vehname[1500];"
oh god.
18 is enough.
Re: GetVehicleName - Simple, Easy & Efficient function. -
dominik523 - 08.03.2015
This isn't really for an include, it's for useful snippets of code.
But, nice work I guess.
Re: GetVehicleName - Simple, Easy & Efficient function. -
Gammix - 08.03.2015
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))
{
....
Re: GetVehicleName - Simple, Easy & Efficient function. -
HY - 08.03.2015
Quote:
Originally Posted by Ralfie
An array with the names is better.
|
Thanks anyway.
Quote:
Originally Posted by M4D
Nice job but this function can post on Useful Functions Topic !
anyway good job !
|
Thanks.
Quote:
Originally Posted by Kyance
"new vehname[1500];"
oh god.
18 is enough.
|
Lol, edited.
Quote:
Originally Posted by dominik523
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
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!
Re: GetVehicleName - Simple, Easy & Efficient function. -
Gammix - 08.03.2015
EDIT: the param
vehicleid must be
modelid.
I think rest is solved.
Re: GetVehicleName - Simple, Easy & Efficient function. -
Yashas - 08.03.2015
Arrays would be faster here.
If you wish to keep the switch, then add a default where you must return "NONE" or something similar.
Re: GetVehicleName - Simple, Easy & Efficient function. -
Airblog - 08.03.2015
Good Work