Exsample for dealership
#1

Hello i was recently stuck in a problem where i can't figure out how i can make a car spawn with CreateVehicle if anyone of you have a way to spawn a vehicle with CreateVehicle outside OnGameModeInit i would really appreciate it.
Reply
#2

Here you go, Hopefully this has helped you

Quote:

new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
new carid = CreateVehicle(VEHICLEIDHERE, X,Y,Z, 0.0, -1, -1, -1);

You can use CreateVehicle anywhere, It doesnt have to be in OnGamemodeInit
Reply
#3

that's the exact thing i am using right now but the vehicle doesn't spawn.
Reply
#4

Show me the section of the code where the car spawns. Ill fix it for ya
Reply
#5

pawn Код:
public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, Time);
    TextDrawShowForPlayer(playerid, Calander);
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid,x,y,z);
    carid = CreateVehicle(411,x,y,z,0.0,0,0,60);
    return 1;
}
i don't know if you can do it on spawn. its just a test.
Reply
#6

Do not do that - Thats a big No No.

Try This It Should Fix It

Код:
public OnPlayerSpawn(playerid)
{
    TextDrawShowForPlayer(playerid, Time);
    TextDrawShowForPlayer(playerid, Calander);
    SetTimerEx("SpawnPlayerVehicle", 5000, false, "i", playerid);
    return 1;
}

forward SpawnPlayerVehicle(playerid);
public SpawnPlayerVehicle()
{
	if(IsPlayerConnected(playerid)) // You should add a new ENUM varible like Spawned == 1 etc
	{
	    new Float:x, Float:y, Float:z;
	    GetPlayerPos(playerid,x,y,z);
	    CreateVehicle(411,x,y,z,0.0,0,0,60);
	}
	return 1;
}
Reply
#7

Using ZCMD:

pawn Код:
CMD:veh(playerid,params[])
{
    if(P_Info[playerid][Admin] >= 4) {
//        Use the below line, if you have a engine script.
//        new lights,alarm,doors,bonnet,boot,objective;
        new Float:Pos[3], model, Col[2], CreatedCar;
        if(sscanf(params,"iii",model,Col[0],Col[1])) return SendClientMessage(playerid, -1, "SYNTAX: /veh [model] [Color-1] [Color-2]");
        GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
        CreatedCar = CreateVehicle(model,Pos[0],Pos[1],Pos[2],0.0,Col[0],Col[1],60000);
        new vw = GetPlayerVirtualWorld(playerid);
        SetVehicleVirtualWorld(CreatedCar, vw);
        PutPlayerInVehicle(playerid, CreatedCar, 0);
        // Use SetVehicleParams if you have a engine script.
//      SetVehicleParamsEx(CreatedCar,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
    }
    return 1;
}
Reply
#8

No result same problem i don't why it is happening.

EDIT: my goal is to make a roleplay dealership i don't need commands.
Reply
#9

Try the code now, I updated it.
Now it sets the vehicles VW To your VW. As that could of been the issue as-well.
Reply
#10

Quote:
Originally Posted by Lynn
Посмотреть сообщение
Try the code now, I updated it.
Now it sets the vehicles VW To your VW. As that could of been the issue as-well.
Do you not understand him, He needs it for a uncontrollable Dealership, meaning no commands.

I'll just create you a working Dealership and PM you it tonight.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)