[HELP] Vehicle Spawner -
Povis - 10.07.2014
Hello, I'm creating a vehicle spawner and I have few problems. First, I only can spawn one car till the server is online (if I want to spawn another car, I must restart server). Second, my "destroy" command doesn't work and I can't understand why. Third, then spawned vehicle explodes, it respawns where was the first time spawned. And I also got fed warnings, I would appreciate help. Thank you.
There is my code:
Код:
//----- Defines -----//
new SpawnedVehicle[MAX_PLAYERS];
//----- Enums -----//
enum
{
DIALOG_VEHICLE
}
Код:
//----- Generated Commands -----//
CMD:vehicle(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(SpawnedVehicle[playerid] == 0)
{
ShowPlayerDialog(playerid, DIALOG_VEHICLE, DIALOG_STYLE_INPUT, "Maрinш sistema", " Labukas :P", "Spawn", "Close");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, "Jыs jau turite maрinа.");
return 1;
}
}
return 1;
}
CMD:destroy(playerid, params[])
{
if(SpawnedVehicle[playerid] == 0) return SendClientMessage(playerid, COLOR_YELLOW, "Server Error: Tu negali sunaikinti masinos, kurios neturi");
DestroyVehicle(SpawnedVehicle[playerid]);
SpawnedVehicle[playerid] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "Jus sunaikinote savo masina");
return 1;
}
Код:
//----- Generated Publics -----//
public LoadPlayer(playerid, name[], value[])
{
SpawnedVehicle[playerid] = 0;
return 1;
}
Код:
//----- Stocks -----//
stock SpawnVehicleForPlayer(vehicleid, playerid)
{
if(SpawnedVehicle[playerid] != 0)
{
DestroyVehicle(SpawnedVehicle[playerid]);
}
new Float:X, Float:Y, Float:Z, Float:Angle;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Angle);
SpawnedVehicle[playerid] = CreateVehicle(vehicleid, X, Y, Z+2, Angle, -1, -1, -1);
SetVehicleVirtualWorld(SpawnedVehicle[playerid], GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(SpawnedVehicle[playerid], GetPlayerInterior(playerid));
PutPlayerInVehicle(playerid, SpawnedVehicle[playerid = 0]);
}
And few errors:
Код:
C:\Users\Magahaka\Documents\samp03z_svr_R1_win32\gamemodes\Gamemode.pwn(136) : warning 235: public function lacks forward declaration (symbol "LoadPlayer")
C:\Users\Magahaka\Documents\samp03z_svr_R1_win32\gamemodes\Gamemode.pwn(169) : warning 213: tag mismatch
C:\Users\Magahaka\Documents\samp03z_svr_R1_win32\gamemodes\Gamemode.pwn(176) : warning 213: tag mismatch
C:\Users\Magahaka\Documents\samp03z_svr_R1_win32\gamemodes\Gamemode.pwn(176) : warning 213: tag mismatch
C:\Users\Magahaka\Documents\samp03z_svr_R1_win32\gamemodes\Gamemode.pwn(205) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
5 Warnings.
Re: [HELP] Vehicle Spawner -
Povis - 10.07.2014
Bump
Re: [HELP] Vehicle Spawner -
DavidSparks - 10.07.2014
The last one, its not errors. Its warnings. The warnings doesnt matter mate. The script can still be running.
Re: [HELP] Vehicle Spawner -
Povis - 11.07.2014
That's the point, script doesn't work properly and there are few problems in game with this script:
First, I only can spawn one car till the server is online (if I want to spawn another car, I must restart server). Second, my "destroy" command doesn't work and I can't understand why. Third, then spawned vehicle explodes, it respawns where was the first time spawned. And I also got few warnings, I would appreciate help. Thank you.
Re: [HELP] Vehicle Spawner -
ABKPot - 11.07.2014
Cause you keep setting the variable to 0, and your playerid 0
pawn Код:
CMD:vehicle(playerid, params[])
{
if(SpawnedVehicle[playerid] == -1)
{
ShowPlayerDialog(playerid, DIALOG_VEHICLE, DIALOG_STYLE_INPUT, "Maрinш sistema", " Labukas :P", "Spawn", "Close");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_YELLOW, "Jыs jau turite maрinа.");
return 1;
}
return 1;
}
CMD:destroy(playerid, params[])
{
if(SpawnedVehicle[playerid] == -1) return SendClientMessage(playerid, COLOR_YELLOW, "Server Error: Tu negali sunaikinti masinos, kurios neturi");
DestroyVehicle(SpawnedVehicle[playerid]);
SpawnedVehicle[playerid] = -1;
SendClientMessage(playerid, COLOR_YELLOW, "Jus sunaikinote savo masina");
return 1;
}
forward LoadPlayer(playerid, name[], value[]);
public LoadPlayer(playerid, name[], value[])
{
SpawnedVehicle[playerid] = -1;
return 1;
}
stock SpawnVehicleForPlayer(vehicleid, playerid)
{
if(SpawnedVehicle[playerid] != -1)
{
DestroyVehicle(SpawnedVehicle[playerid]);
}
new Float:X, Float:Y, Float:Z, Float:Angle;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Angle);
SpawnedVehicle[playerid] = CreateVehicle(vehicleid, X, Y, Z+2, Angle, -1, -1, -1);
SetVehicleVirtualWorld(SpawnedVehicle[playerid], GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(SpawnedVehicle[playerid], GetPlayerInterior(playerid));
PutPlayerInVehicle(playerid, SpawnedVehicle[playerid]);
}