car spawner
#1

i tries this so many times and i failed alot. i wanted to make this show a dialog when the players didnt type anything with /v. i mean like if a player type /v infernus he will spawn an infernus. and when that same player type /v and dont type anything, it will show him a vehicle dialog.
Код:
 CMD:v(playerid, params[])
{
	new string[128], vID[32], vid, Float:x, Float:y, Float:z, Float:ang;
	if(sscanf(params, "s[32]", vID)) return SendClientMessage(playerid, COLOR_RED, "Syntax: /v (carname)");
	if(isnumeric(vID)) vid = strval(vID);
	else vid = GetVehicleModelIDFromName(vID);
	if (vid < 400 || vid > 611) return SendClientMessage(playerid, COLOR_RED, "Vehicle ID Maxium (Left): 400 - Maxium (Right): 611");
	GetPlayerPos(playerid,x,y,z);
	GetPlayerFacingAngle(playerid,ang);
	if(PlayerVehicle[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(PlayerVehicle[playerid]);
	PlayerVehicle[playerid] = CreateVehicle(vid, x, y, z, ang, -1, -1, 6000);
	LinkVehicleToInterior(PlayerVehicle[playerid], GetPlayerInterior(playerid));
	SetVehicleVirtualWorld(PlayerVehicle[playerid], GetPlayerVirtualWorld(playerid));
	PutPlayerInVehicle(playerid, PlayerVehicle[playerid], 0);
	return 1;
}
vehicle dialog code
Код:
 		new allvehicles[] = "1\tAirplanes\n2\tHelicopters\n3\tBikes\n4\tConvertibles\n5\tIndustrial\n6\tLowriders\n7\tOffRoad\n8\tPublic Service Vehicles\n9\tSaloons\n10\tSport Vehicles\n11\tStation Wagons\n12\tBoats\n13\tUnique Vehicles\n14\tRC Vehicles\n15\tTrailers";
	   	ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST," Vehicles: || Scroll Down for more",allvehicles,"Select","Cancel");
i really need the command like that.
Reply
#2

-----
Reply
#3

really need help making the command like this but you might not understand what im explaining.
Reply
#4

Bumping your thread won't solve anything. Use that damn edit button.
And if you search you'll see that some people already made scripts like what you're looking for.
Reply
#5

PHP код:
CMD:v(playeridparams[])
{
    new 
string[128], vID[32], vidFloat:xFloat:yFloat:zFloat:ang;
        if(
sscanf(params"s[32]"vID)) return ShowPlayerDialog //Your definition
    
if(isnumeric(vID)) vid strval(vID);
    else 
vid GetVehicleModelIDFromName(vID);
    if (
vid 400 || vid 611) return SendClientMessage(playeridCOLOR_RED"Vehicle ID Maxium (Left): 400 - Maxium (Right): 611");
    
GetPlayerPos(playerid,x,y,z);
    
GetPlayerFacingAngle(playerid,ang);
    if(
PlayerVehicle[playerid] != INVALID_VEHICLE_IDDestroyVehicle(PlayerVehicle[playerid]);
    
PlayerVehicle[playerid] = CreateVehicle(vidxyzang, -1, -16000);
    
LinkVehicleToInterior(PlayerVehicle[playerid], GetPlayerInterior(playerid));
    
SetVehicleVirtualWorld(PlayerVehicle[playerid], GetPlayerVirtualWorld(playerid));
    
PutPlayerInVehicle(playeridPlayerVehicle[playerid], 0);
    return 
1;

Reply
#6

Quote:
Originally Posted by KillerDVX
Посмотреть сообщение
PHP код:
CMD:v(playeridparams[])
{
    new 
string[128], vID[32], vidFloat:xFloat:yFloat:zFloat:ang;
        if(
sscanf(params"s[32]"vID)) return ShowPlayerDialog //Your definition
    
if(isnumeric(vID)) vid strval(vID);
    else 
vid GetVehicleModelIDFromName(vID);
    if (
vid 400 || vid 611) return SendClientMessage(playeridCOLOR_RED"Vehicle ID Maxium (Left): 400 - Maxium (Right): 611");
    
GetPlayerPos(playerid,x,y,z);
    
GetPlayerFacingAngle(playerid,ang);
    if(
PlayerVehicle[playerid] != INVALID_VEHICLE_IDDestroyVehicle(PlayerVehicle[playerid]);
    
PlayerVehicle[playerid] = CreateVehicle(vidxyzang, -1, -16000);
    
LinkVehicleToInterior(PlayerVehicle[playerid], GetPlayerInterior(playerid));
    
SetVehicleVirtualWorld(PlayerVehicle[playerid], GetPlayerVirtualWorld(playerid));
    
PutPlayerInVehicle(playeridPlayerVehicle[playerid], 0);
    return 
1;

thx man it work perfect! +REP
Reply
#7

one thing, when I /v infer and then /v nrg the, infernus destroy before the nrg. but when I /v infernus then /v(blank) and choose a vehicle from the dialog, it put me in the vehicle I choose from the dialog but doesn't delete the infernus. any ideas how to solve this?
Reply
#8

You probably forgot to put the
pawn Код:
if(PlayerVehicle[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(PlayerVehicle[playerid]);
line in the dialog's response.
Reply
#9

thx +rep I found the problem. I added
Quote:

new PlayerVehicle[MAX_PLAYERS];

and the
Quote:

if(PlayerVehicle[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(PlayerVehicle[playerid]);

right under
Quote:

public OnDialogResponse

I removed
Quote:

new PlayerVehicle[MAX_PLAYERS];

and the
Quote:

if(PlayerVehicle[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(PlayerVehicle[playerid]);

and put
Quote:

if(PlayerVehicle[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(PlayerVehicle[playerid]);

in the right postion and it's working now thanks again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)