#1

Yo!
Well the problem is when u type /veh you can only type the id of the car and it takes some times to find out the id of the car. So i have noticed that some servers that you can both type the car name and the id. How to do it like that?
Here is the command
Код:
CMD:veh(playerid, params[]) {
	if (PlayerInfo[playerid][pAdmin] >= 4) {

		new
			iVehicle,
			iColors[2];

		if(sscanf(params, "iii", iVehicle, iColors[0], iColors[1])) {
			SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /veh [model ID] [color 1] [color 2]");
		}
		else if(!(400 <= iVehicle <= 611)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid model specified (model IDs start at 400, and end at 611).");
		}
		else if(!(0 <= iColors[0] <= 255 && 0 <= iColors[1] <= 255)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid colour specified (IDs start at 0, and end at 255).");
		}
		else for(new iIterator; iIterator < sizeof(CreatedCars); iIterator++) if(CreatedCars[iIterator] == INVALID_VEHICLE_ID) {

			new
				Float: fVehPos[4];

			GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]);
			GetPlayerFacingAngle(playerid, fVehPos[3]);
			CreatedCars[iIterator] = AddStaticVehicleEx(iVehicle, fVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1);
			VehicleFuel[CreatedCars[iIterator]] = 100.0;
			LinkVehicleToInterior(CreatedCars[iIterator], GetPlayerInterior(playerid));
			return SendClientMessageEx(playerid, COLOR_GREY, "Vehicle spawned!");
		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
	return 1;
}
Reply
#2

Just read through this FS, try understand it then try put it in your script.
https://sampforum.blast.hk/showthread.php?tid=346727
Reply
#3

try this one
pawn Код:
CMD:veh(playerid, params[]) {
    if (PlayerInfo[playerid][pAdmin] >= 4) {

        new iColors[2], vName[32];

        if(!sscanf(params, "s[32]ii", vName, iColors[0], iColors[1]))
        {
            new idx;
            if (!IsNumeric(vName))
            {
                idx = GetVehicleModelIDFromName(vName);
            }
            else
            {
                idx = strval(vName);
            }

            if( idx != -1 )
            {
                if(idx > MIN_VEHI_ID && idx < MAX_VEHI_ID)
                {
                    if(!(0 <= iColors[0] <= 255 && 0 <= iColors[1] <= 255)) {
                        SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid colour specified (IDs start at 0, and end at 255).");
                    }
                    else for(new iIterator; iIterator < sizeof(CreatedCars); iIterator++) if(CreatedCars[iIterator] == INVALID_VEHICLE_ID) {

                        new
                            Float: fVehPos[4], string[128];

                        GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]);
                        GetPlayerFacingAngle(playerid, fVehPos[3]);
                        CreatedCars[iIterator] = CreateVehicleEx(idx, fVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1);
                        VehicleFuel[CreatedCars[iIterator]] = 100.0;
                        Gas[CreatedCars[iIterator]] =100.0;
                        LinkVehicleToInterior(CreatedCars[iIterator], GetPlayerInterior(playerid));

                        format(string, sizeof(string), "Successfully spawned a %s (Vehicle Model: %d, Vehicle ID: %d, Color 1: %d, Color 2: %d)", VehicleName[idx - MIN_VEHI_ID], idx, CreatedCars[iIterator], iColors[0], iColors[1]);
                        return SendClientMessageEx(playerid, COLOR_GREY, string);
                    }
                }
                else
                {
                    SendClientMessageEx(playerid, COLOR_GRAD2, "  Invalid Model Name/ID");
                }
            }
            else
            {
                SendClientMessageEx(playerid, COLOR_GRAD2, "  Invalid Model Name/ID!");
            }
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /veh [Model ID/Name] [color 1] [color 2]");
            return 1;
        }
    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    return 1;
}
i got it from my script.
Reply
#4

i have made this one quick for you..:
pawn Код:
CMD:veh(playerid, params[])
{
        if(!(PlayerInfo[playerid][pAdmin] >= 4))
            return SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use this command.");

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
            return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [vehicle name/ID] [color1(optional)] [color2(optional)]");

        new car = ReturnVehicleModelID(tmp);
        if(!car)
            return SendClientMessage(playerid, COLOR_GREY, "   Invalid vehicle model name/ID.");

            new color1, color2;
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                    color1 = -1;
                    color2 = -1;
        }
        else
        {
            color1 = strval(tmp);
            if(color1 < -1 || color1 > 200)
                return SendClientMessage(playerid, COLOR_GREY, "   Enter a valid color [0-200]");

                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp)) color2 = color1;
                    else color2 = strval(tmp);
                    if(color2 < -1 || color2 > 200)
                return SendClientMessage(playerid, COLOR_GREY, "   Enter a valid color [0-200]");
        }

        if(IsPlayerInAnyVehicle(playerid))
            RemovePlayerFromVehicle(playerid);
        new Float:X, Float:Y, Float:Z, Float:A;
                GetPlayerPos(playerid, X,Y,Z);
        GetPlayerFacingAngle(playerid,A);
        new carid = CreateVehicle(car, X,Y,Z,A, color1, color2, -1);

        PutPlayerInVehicle(playerid,carid,0);
        LinkVehicleToInterior(carid,GetPlayerInterior(playerid));
        SendClientMessage(playerid, -1, "You have spawned a vehicle");
        return 1;
}
and add this anywhere in your script:
pawn Код:
stock ReturnVehicleModelID(string[])
{
    if(IsNumeric(string))
    {
        new id = strval(string);
        if(id >= 400 && id <= 611)
        {
            return id;
        }
    }
    for(new i = 0;i < sizeof(vehName);i++)
    {
        if(strfind(vehName[i],string,true) != -1)
        {
            return i + 400;
        }
    }
    return 0;
}
Reply
#5

Quote:
Originally Posted by Drago987
Посмотреть сообщение
try this one
pawn Код:
CMD:veh(playerid, params[]) {
    if (PlayerInfo[playerid][pAdmin] >= 4) {

        new iColors[2], vName[32];

        if(!sscanf(params, "s[32]ii", vName, iColors[0], iColors[1]))
        {
            new idx;
            if (!IsNumeric(vName))
            {
                idx = GetVehicleModelIDFromName(vName);
            }
            else
            {
                idx = strval(vName);
            }

            if( idx != -1 )
            {
                if(idx > MIN_VEHI_ID && idx < MAX_VEHI_ID)
                {
                    if(!(0 <= iColors[0] <= 255 && 0 <= iColors[1] <= 255)) {
                        SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid colour specified (IDs start at 0, and end at 255).");
                    }
                    else for(new iIterator; iIterator < sizeof(CreatedCars); iIterator++) if(CreatedCars[iIterator] == INVALID_VEHICLE_ID) {

                        new
                            Float: fVehPos[4], string[128];

                        GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]);
                        GetPlayerFacingAngle(playerid, fVehPos[3]);
                        CreatedCars[iIterator] = CreateVehicleEx(idx, fVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1);
                        VehicleFuel[CreatedCars[iIterator]] = 100.0;
                        Gas[CreatedCars[iIterator]] =100.0;
                        LinkVehicleToInterior(CreatedCars[iIterator], GetPlayerInterior(playerid));

                        format(string, sizeof(string), "Successfully spawned a %s (Vehicle Model: %d, Vehicle ID: %d, Color 1: %d, Color 2: %d)", VehicleName[idx - MIN_VEHI_ID], idx, CreatedCars[iIterator], iColors[0], iColors[1]);
                        return SendClientMessageEx(playerid, COLOR_GREY, string);
                    }
                }
                else
                {
                    SendClientMessageEx(playerid, COLOR_GRAD2, "  Invalid Model Name/ID");
                }
            }
            else
            {
                SendClientMessageEx(playerid, COLOR_GRAD2, "  Invalid Model Name/ID!");
            }
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /veh [Model ID/Name] [color 1] [color 2]");
            return 1;
        }
    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    return 1;
}
i got it from my script.
Its not yours you just stole it thats all... Its from the Project Los Angeles Script. I bet he just gonna go around handing commands out from script then we gonna have a problem with a NDA. Garret...
Reply
#6

Ah okay future
Reply
#7

Not you XK, im talking about Drago he has got the PLA script and giving out commands and he knows we are after him... Mike Gere and I are after you garret, if you start releasing the code inside of the script its not going so hard
Reply
#8

Thanks
Reply
#9

Quote:
Originally Posted by FutureGenerationGaming
Посмотреть сообщение
Not you XK, im talking about Drago he has got the PLA script and giving out commands and he knows we are after him... Mike Gere and I are after you garret, if you start releasing the code inside of the script its not going so hard
Not gunna start a agrument, I'm sure the whole of SA:MP adminstration knows that Steve released what he made, so it's not stolen.

Hush little boy, don't you cry.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)