/veh with name instead of id.
#1

Hey, got a problem, I got a /veh command but I need to fill in the vehicle id, I cannot put in the vehicle's name, how to fix that?

For example:

/veh 560 0 0

I want:

/veh sultan 0 0

Код:
YCMD:veh(playerid, params[], help)
{
	if(help) return SCM(playerid, COLOR_GREY, "Not supported");

    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
    	new model, iColor[2], vid, Float:x, Float:y, Float:z, Float:angle;
    	new engine,lights,alarm,doors,bonnet,boot,objective;
    	if(sscanf(params,"dii",model, iColor[0],iColor[1])) return SCM(playerid, COLOR_GRAD, "USAGE: /veh [model id] [color1] [color2]");
    	if(model < 400 || model > 611) return SCM(playerid, COLOR_GREY, "[DEBUG]: Vehicle ID's must be between 400 - 611.");
   		if(iColor[1] < 0 && iColor[1] > 126)
		{
			SCM(playerid, COLOR_GREY, "Invalid color ID.");
		}
    	GetPlayerPos(playerid, x, y, z);
     	GetPlayerFacingAngle(playerid, angle);
    	vid = CreateVehicle(model, x, y, z, angle, iColor[0], iColor[1], -1);
    	GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
    	SetVehicleParamsEx(vid, 1, lights, alarm, doors, bonnet, boot, objective);
		engineOn[vid] = true;
    	SetVehicleNumberPlate(vid, "ADMIN");
    	PutPlayerInVehicle(playerid, vid, 0);
    }
    return 1;
}
Thanks!
Reply
#2

If you use <name> <color1> <color2>, then keep in mind that you can use only 1 word for the vehicle's name unless you add the name last. I think it's better to use: /veh <vehicle name> only and add random colors. Then you can change the color with another command.

http://forum.sa-mp.com/showthread.ph...17#post2969117
Reply
#3

I suggest you /v in dialog, something like this:
http://pastebin.com/f114bd185 (Not my code!)
Reply
#4

Well.. What about /veh *car name* *col1 name* *col2name* I know that's possible, just don't know how yet .
Reply
#5

pawn Код:
YCMD:veh(playerid, params[], help)
{
    if(help) return SCM(playerid, COLOR_GREY, "Not supported");
   
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
        new veh_name[32], iColor[2];
        if(sscanf(params,"s[32]ii",veh_name, iColor[0],iColor[1])) return SCM(playerid, COLOR_GRAD, "USAGE: /veh [vehicle name] [color1] [color2]");
        new model = GetVehicleModelIDFromName(veh_name);
        if(model == -1) return SCM(playerid, COLOR_GREY, "Invalid vehicle name");
        if(iColor[1] < 0 && iColor[1] > 126) return SCM(playerid, COLOR_GREY, "Invalid color ID.");
        new vid, Float:x, Float:y, Float:z, Float:angle, engine,lights,alarm,doors,bonnet,boot,objective;
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, angle);
        vid = CreateVehicle(model, x, y, z, angle, iColor[0], iColor[1], -1);
        GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
        SetVehicleParamsEx(vid, 1, lights, alarm, doors, bonnet, boot, objective);
        engineOn[vid] = true;
        SetVehicleNumberPlate(vid, "ADMIN");
        PutPlayerInVehicle(playerid, vid, 0);
    }
    return 1;
}
Reply
#6

OP, read the posts people make, atleast acknowledge them, we do not get paid for this!

You'd be posting right now - "GetVehicleNameFromID" is an undefined function, etc, so visit the link the above poster has given. The function there is still incorrect - TBH, you should keep a counter of the number of character matches, then return the ID with the most matches.
Reply
#7

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
The function there is still incorrect - TBH, you should keep a counter of the number of character matches, then return the ID with the most matches.
I don't think that's the best way. That function is old but still, it works fine.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)