Two things I need help with
#1

The first thing I need help with is being able to limit the car ID that can be chosen with my spawn car command. Basically if the user of the command chooses a car ID below 400 and above 611 it comes up with an error message.

My includes:

Код:
#include <a_samp>
#include <core>
#include <float>
#include <sscanf2>
#include <zcmd>
#include <foreach>
The command:

Код:
CMD:spawnveh(playerid, params[]) 
{
	new  Float:x, Float:y, Float:z, Float:ang, 
		color1, color2, id;
		
		
	
	{
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not an admin!"); 
		{
		if(sscanf(params, "iii", id, color1, color2)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /spawnveh [400-611] [color id] [color id]");
		GetPlayerPos(playerid,x,y,z);
		GetPlayerFacingAngle(playerid, ang);
		CreateVehicle(id, x, y, z, ang, color1, color2, 90000);
		SendClientMessage(playerid, COLOR_GREEN, "You have spawned a car!");
		}
			
	return 1;
	}
}
The second thing I need help with is being able to turn on a car engine and turn it off with the same command. At the moment I have it as two separate commands and I would like to know how I can make them one command. Same script as the last command so its the same includes.

Commands:

Код:
CMD:engineon(playerid, params[])
{
	new vehicle, string[128], engine, lights, alarm, doors, bonnent, boot, objective; 
	
	vehicle = GetPlayerVehicleID(playerid);
	{
	if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not in any vehicle!");
	GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnent, boot, objective); 
	SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnent, boot, objective);
	format(string, sizeof(string), "%s puts their keys in the ignition and starts the car.", GetName(playerid)); 
	ProxDetector(30, playerid, string, COLOR_PURPLE);
	}
	return 1;
} 
	
CMD:engineoff(playerid, params[])
{
	new vehicle, string[128], engine, lights, alarm, doors, bonnent, boot, objective;
	
	vehicle = GetPlayerVehicleID(playerid);
	{
	if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not in any vehicle!");
	GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnent, boot, objective);
	SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnent, boot, objective);
	format(string, sizeof(string), "%s takes their keys out of the ignition and shuts off the car.", GetName(playerid));
	ProxDetector(30, playerid, string, COLOR_PURPLE);
	}	
	return 1;
}
Thanks for any help you provide!
Reply
#2

pawn Код:
if(id > 399 && id < 612) //if id is bigger than 399 and lower than 612
{
//spawn the vehicle
}
Reply
#3

Quote:
Originally Posted by miokie
Посмотреть сообщение
pawn Код:
if(id > 399 && id < 612) //if id is bigger than 399 and lower than 612
{
//spawn the vehicle
}
Thanks! I tried doing this before but I didn't know I needed to put "id" a second time.
Reply
#4

This should cover your /engineon and /engineoff commands;

pawn Код:
new IsEngineOn[MAX_VEHICLES];

CMD:engine(playerid, params[])
{
    new vehicle, string[128], engine, lights, alarm, doors, bonnent, boot, objective;
    vehicle = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnent, boot, objective);
    if(!IsPlayerInAnyVehicle(playerid))
        {
        SendClientMessage(playerid, COLOR_RED, "You are not in any vehicle!");
        return 1;
        }
    if(IsEngineOn[vehicle] == 0)
        {
        SetVehicleParamsEx(vehicle, 1, lights, alarm, doors, bonnent, boot, objective);
        IsEngineOn[vehicle] = 1;
        format(string, sizeof(string), "%s puts their keys in the ignition and starts the car.", GetName(playerid));
        }
    else if(IsEngineOn[vehicle] == 1)
        {
        SetVehicleParamsEx(vehicle, 0, lights, alarm, doors, bonnent, boot, objective);
        IsEngineOn[vehicle] = 0;
        format(string, sizeof(string), "%s takes their keys out of the ignition and shuts off the car.", GetName(playerid));
        }
    ProxDetector(30, playerid, string, COLOR_PURPLE);
    return 1;
}
Best regards,
Jesse
Reply
#5

Quote:
Originally Posted by jessejanssen
Посмотреть сообщение
This should cover your /engineon and /engineoff commands;

pawn Код:
new IsEngineOn[MAX_VEHICLES];
Best regards,
Jesse
Where do I put that on the script? (Noob question, I know :P)
Reply
#6

Quote:
Originally Posted by Chenko
Посмотреть сообщение
Where do I put that on the script? (Noob question, I know :P)
The new EngineOn[MAX_VEHICLES] will got at the top of the script, wherever the rest of your "new's" are.

the CMD will go where the CMD goes. :3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)