Vehicle Help -
Desertsoulz - 27.02.2011
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.
Re: Vehicle Help -
maramizo - 27.02.2011
Remove the public OnPlayerCommandText.
Also there's a probability that an FS is fucking your script up.
Re: Vehicle Help -
Desertsoulz - 27.02.2011
I have no filterscripts loaded, and I can't find the public OnPlayrCommandText anywhere.
Re: Vehicle Help -
maramizo - 27.02.2011
That's because it's OnPlayerCommandText. Not OnPlayrCommandText.
Re: Vehicle Help -
Desertsoulz - 27.02.2011
I'm not stupid, my keyboard just is a little sticky >.>
Its not there bro I checked.
Re: Vehicle Help -
maramizo - 27.02.2011
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;
}
Re: Vehicle Help -
Desertsoulz - 27.02.2011
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.
Re: Vehicle Help -
maramizo - 27.02.2011
https://sampforum.blast.hk/showthread.php?tid=206237
Re: Vehicle Help -
Desertsoulz - 27.02.2011
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?
Re: Vehicle Help -
admantis - 27.02.2011
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
}