Vehicle Help
#1

I need help with spawning cars in-game.
I was making the code for it but..
It compiles correctly,
But when I try it in-game, it don't work. I type /spawncar 420 (taxi) but nothing happens even the error message doesn't show up.

Here's my code:
Код:
CMD:spawncar(playerid, params[])
{
	new PlayerName[MAX_PLAYER_NAME],file[256],VehID,Float:VehX,Float:VehY,Float:VehZ,Float:VehA,SpawnedCar,string[128];
	GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	format(file, sizeof(file), ACCOUNT_FILE, PlayerName);
	
	if(sscanf(params, "i", VehID))
	{
		if(dini_Int(file, "AdminLevel") > 0)
		{
			if(VehID < 400 || VehID > 611)
			{
				SendClientMessage(playerid,SystemMSG,"[VEHICLE]: Invalid Vehicle Model, Vehicle Models range from 400-611.");
				return 1;
			}
			GetPlayerPos(playerid,VehX,VehY,VehZ);
			GetPlayerFacingAngle(playerid,VehA);

			SpawnedCar = CreateVehicle(VehID,VehX,VehY,VehZ,VehA,-1,-1,-1);
			LinkVehicleToInterior(SpawnedCar, GetPlayerInterior(playerid));
			SetVehicleVirtualWorld(SpawnedCar, GetPlayerVirtualWorld(playerid));

			PutPlayerInVehicle(playerid,SpawnedCar,0);
			format(string, 128, "[VEHICLE]: You have successfully spawned Vehicle Model %d!", VehID);
			SendClientMessage(playerid, SystemMSG, string);
		}
		else
		{
			SendClientMessage(playerid,SystemMSG,"[VEHICLE]: You need to be an Administrator to use that command!");
		}
	}
	return true;
}
I am using <zcmd> and <sscanf> and I am new to Pawn.

Please help me.
Reply
#2

Remove the public OnPlayerCommandText.
Also there's a probability that an FS is fucking your script up.
Reply
#3

I have no filterscripts loaded, and I can't find the public OnPlayrCommandText anywhere.
Reply
#4

That's because it's OnPlayerCommandText. Not OnPlayrCommandText.
Reply
#5

I'm not stupid, my keyboard just is a little sticky >.>
Its not there bro I checked.
Reply
#6

You misused sscanf.
pawn Код:
CMD:spawncar(playerid, params[])
{
    new PlayerName[MAX_PLAYER_NAME],file[256],VehID,Float:VehX,Float:VehY,Float:VehZ,Float:VehA,SpawnedCar,string[128];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    format(file, sizeof(file), ACCOUNT_FILE, PlayerName);

    if(sscanf(params, "i", VehID)) return SendClientMessage(playerid, SystemMSG,"USAGE: /spawncar [VehicleID]");
    if(dini_Int(file, "AdminLevel") > 0)
        {
            if(VehID < 400 || VehID > 611)
            {
                SendClientMessage(playerid,SystemMSG,"[VEHICLE]: Invalid Vehicle Model, Vehicle Models range from 400-611.");
                return 1;
            }
            GetPlayerPos(playerid,VehX,VehY,VehZ);
            GetPlayerFacingAngle(playerid,VehA);

            SpawnedCar = CreateVehicle(VehID,VehX,VehY,VehZ,VehA,-1,-1,-1);
            LinkVehicleToInterior(SpawnedCar, GetPlayerInterior(playerid));
            SetVehicleVirtualWorld(SpawnedCar, GetPlayerVirtualWorld(playerid));

            PutPlayerInVehicle(playerid,SpawnedCar,0);
            format(string, 128, "[VEHICLE]: You have successfully spawned Vehicle Model %d!", VehID);
            SendClientMessage(playerid, SystemMSG, string);
        }
        else
        {
            SendClientMessage(playerid,SystemMSG,"[VEHICLE]: You need to be an Administrator to use that command!");
        }
        return true;
}
Reply
#7

wow thanks...

Sorry its just that I'm new and I don't know what to use...

Do you know a sscanf tutorial? And zcmd? I would appreciate it and thanks alot bro.
Reply
#8

https://sampforum.blast.hk/showthread.php?tid=206237
Reply
#9

Wow two-in-one LOL thanks very much dude.
I have another question, if I wanted to create random hospital spawns, how do I do so?
Reply
#10

Yes you can do this
pawn Код:
switch ( random ( 2 ) )
{
   case 0: SetPlayerPos( x, y, z ); // Hospital 1 positions
   case 1: SetPlayerPos( x, y, z ); // Hospital 2 positions
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)