SA-MP Forums Archive
Command /veh makes the server crash. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Command /veh makes the server crash. (/showthread.php?tid=381507)



Command /veh makes the server crash. - GordonP - 29.09.2012

I have no idea why, the SERVER crashes.

Код:
command(veh, playerid, params[])
{
	new carid, string[128], Float: CarToX, Float: CarToY, Float: CarToZ, physical_car_id;
	if(sscanf(params, "d", carid))
	{
	    if(Player[playerid][AdminLevel] >= 3)
	    {
			SendClientMessage(playerid, WHITE, "Server:  /veh [vehicleid]");
		}
	}
	else
	{
		if(Player[playerid][AdminLevel] >= 3)
		{
	    	if(CarCount < MAX_VEHICLES)
	    	{
				if(carid < 400 || carid > 611)
				{
					SendClientMessage(playerid, WHITE, "Valid car IDs start from 400, ending at 611.");
				    return 1;
				}
				GetPlayerPos(playerid, CarToX, CarToY, CarToZ);
				physical_car_id = CreateVehicle(carid, CarToX, CarToY+4, CarToZ, 90, -1, -1, -1);
				format(string, sizeof(string), "PF11 %i", carid);
				SetVehicleNumberPlate(physical_car_id, string);
				SetVehicleToRespawn(physical_car_id);
				PutPlayerInVehicle(playerid, physical_car_id, 0);
				new vehid = GetPlayerVehicleID(playerid);
				format(string, sizeof(string), "[AdmCmd] %s has spawned a vehicle; Model ID: %d - Vehicle ID: %d", RemoveUnderScore(playerid), carid, vehid);
				SendToAdmins(RED, string, 0);
				fuel[physical_car_id] = 100;
				Player[playerid][KeyShare] = physical_car_id;
				LinkVehicleToInterior(physical_car_id, GetPlayerInterior(playerid));
				Engine[physical_car_id] = 0;
				Windows[physical_car_id] = 0;
				Siren[physical_car_id] = 0;
				SirenObject[physical_car_id] = 0;
				Lights[physical_car_id] = 0;
				AdminSpawned[physical_car_id] = 1;
		    }
		}
		else return SendClientMessage(playerid, GREY, "You must be on Admin Duty to perform this command.");
	}
	return 1;



Re: Command /veh makes the server crash. - Patrick - 29.09.2012

Try Delete That.. And Try Download Just Filterscript so The Server Will Not Crash

The FS Made By: x96664 https://sampforum.blast.hk/showthread.php?tid=346354

Click Rep If I Help You
---------------------


Re: Command /veh makes the server crash. - ShawnMiller1337 - 29.09.2012

Try using this simple command I designed for my script!

pawn Код:
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] = CreateVehicle(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_WHITE, "[SERVER]Vehicle spawned!");
        }
    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
    return 1;
}
+Rep if it helps you


Re: Command /veh makes the server crash. - GordonP - 30.09.2012

It didn't work, Shawn. I had 3 errors.


Re: Command /veh makes the server crash. - Rapk1d - 30.09.2012

Try this.
Код:
if(strcmp(cmd, "/veh", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if (PlayerInfo[playerid][pAdmin] < 4)
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
                return 1;
            }
            new car;
            car = strval(tmp);
            if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GREY, "   Vehicle Number can't be below 400 or above 611 !"); return 1; }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
                return 1;
            }
            new color1;
            color1 = strval(tmp);
            if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [carid] [color1] [color2]");
                return 1;
            }
            new color2;
            color2 = strval(tmp);
            if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 126 !"); return 1; }
            new Float:X,Float:Y,Float:Z;
            GetPlayerPos(playerid, X,Y,Z);
            new carid = CreateVehicle(car, X,Y,Z, 0.0, color1, color2, 60000);
            format(string, sizeof(string), "   Vehicle %d spawned.", carid);
            SendClientMessage(playerid, COLOR_GREY, string);
        }
        return 1;
    }