Vehicle Spawning - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Vehicle Spawning (
/showthread.php?tid=252875)
Vehicle Spawning -
Hobod - 03.05.2011
Ok, so i orginally had the script called s&r or something cant remember the name of it.
I changed the /v around a bit so it suited my server a bit more.
So now i have this but theres this bug where one person can spawn a car and somebody else's vehicle will get deleted vice versa. Which ends up in people crying about it to me but ive not a clue at all how to solve this
Код:
dcmd_v(playerid, params[])
{
new Float:Angle;
new Index;
new tmp[256]; tmp = strtok(params,Index);
new car, string[128];
if(!IsNumeric(tmp)) car = GetVehicleModelIDFromName(tmp);
else car = strval(tmp);
if(car < 400 || car > 611) return SendClientMessage(playerid, red, "Usage: /v (vehicle name)");
if(SpawnedVehicles[playerid] != 0) DestroyVehicle(SpawnedVehicles[playerid]);
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
if(GetPlayerVehicleID(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), Angle) && RemovePlayerFromVehicle(playerid);
else GetPlayerFacingAngle(playerid,Angle);
SpawnedVehicles[playerid] = CreateVehicle(car, X,Y,Z+1, Angle, -1, -1, 1200);
PutPlayerInVehicle(playerid,SpawnedVehicles[playerid],0);
SetVehicleZAngle(GetPlayerVehicleID(playerid), Angle);
LinkVehicleToInterior(GetPlayerVehicleID(playerid),GetPlayerInterior(playerid));
SetVehicleVirtualWorld(GetPlayerVehicleID(playerid),GetPlayerVirtualWorld(playerid));
format(string, sizeof(string), "You spawned a %s.", VehicleNames[car-400]);
return SendClientMessage(playerid,sexyblue,string);
}
Re: Vehicle Spawning -
Hobod - 07.05.2011
bump
i really need help with this!
Re: Vehicle Spawning -
eDz0r - 07.05.2011
pawn Код:
dcmd_vspawn(playerid, params[])
{
new modelid, color1, color2;
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid, SYSTEMERROR_COLOR, "[SYSTEM]: You Have Already A Vehicle");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid))
{
if(sscanf(params, "ddd", modelid, color1, color2))
{
SendClientMessage(playerid, SYSTEMERROR_COLOR, "[SYSTEM]: /vspawn [Vehicle Model ID] [Vehicle Color 1 ID] [Vehicle Color 2 ID]");
return 1;
}
else if(modelid < 400 || modelid > 611)
{
SendClientMessage(playerid, SYSTEMERROR_COLOR, "[SYSTEM]: Vehicle Model ID Can't Be Below 400 Or Above 611");
return 1;
}
else if(color1 < 0 || color1 > 126)
{
SendClientMessage(playerid, SYSTEMERROR_COLOR, "[SYSTEM]: Vehicle Color 1 ID Can't Be Below 0 Or Above 126");
return 1;
}
else if(color2 < 0 || color2 > 126)
{
SendClientMessage(playerid, SYSTEMERROR_COLOR, "[SYSTEM]: Vehicle Color 2 ID Can't Be Below 0 Or Above 126");
return 1;
}
else
{
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
new vehicleid = CreateVehicle(modelid, X, Y, Z, A, color1, color2, 0);
PutPlayerInVehicle(playerid, vehicleid, 0);
}
}
return 1;
}
Use mine i will need dcmd and sscanf
Re: Vehicle Spawning -
Hobod - 07.05.2011
by the looks of yours it doesnt delete the last car that a person spawned
mine all works apart from that, it just sometimes seems to delete another persons car like the vehicle ids were getting mixed up