Destroying a vehicle when a player gets out?
#1

So I am fairly new to PAWNO, I just started a couple of months ago, but I'm picking it up pretty quick. I am stuck with a certain part that I am adding into the script for level 9+ admins. I'm making it so they can spawn a hydra at any time, I have the whole spawning part working fine but removing it entirely when they exit the Hydra is something I can't figure out... As well as locking the vehicle when it spawns so that it can't be jacked.

I looked around on the forums and tried many methods that people have posted, which includes assigning a timer with DestroyVehicle and OnPlayerExitVehicle. I have removed all the attempts I made, this script just spawns the hydra with the player inside.
Any help would be much appreciated :P

pawn Код:
dcmd_ahydra(playerid,params[])
{
  #pragma unused params
  if(Variables[playerid][Level] >= 9 && Variables[playerid][LoggedIn] == true)
  {

    new Float:X;
    new Float:Y;
    new Float:Z;
    new Float:Angle;
    new ahydra;
    GetPlayerPos(playerid,X,Y,Z);
    GetPlayerFacingAngle(playerid,Angle);
    ahydra = CreateVehicle(520,X,Y,Z,Angle,-1,-1,-0);
    PutPlayerInVehicle(playerid,ahydra,0);
    TogglePlayerControllable(playerid,true);
    if(GetPlayerInterior(playerid)) LinkVehicleToInterior(ahydra,GetPlayerInterior(playerid));
    SetVehicleVirtualWorld(ahydra,GetPlayerVirtualWorld(playerid));
    return 1;
  }
  return 1;
}
Reply
#2

on top of your script:

Код:
forward destroyhydra(playerid);
Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
  if( ahydra[playerid] > 0 )
  {
	  SetTimerEx("destroyhydra",1000,0, "i", playerid);
	}
		return 1;
}
Код:
public destroyhydra(playerid)
{
		DestroyVehicle(ahydra [playerid]);
		ahydra[playerid] = 0;
		print("A hydra has been destroyed");
}
all these stuff somewhere else in your script where you have all your public's located
Reply
#3

Cheers bud but I am getting this:

Код:
warning 217: loose indentation
error 029: invalid expression, assumed zero
error 004: function "OnPlayerExitVehicle" is not implemented
error 017: undefined symbol "ahydra"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
All of these errors and warnings are in lines 4823 and 4825, where OnPlayerExitVehicle starts. This is a problem I had with some previous attempts. Not too sure what they all mean, I usually don't get so many errors and warnings. There are ignored lines of code within the script that contain OnPlayerExitVehicle, I dunno if they have anything to do with it though.
Reply
#4

Код:
new ahydra[MAX_PLAYERS];
on top of your script

and delete
Код:
new ahydra;
in your command that should work
Reply
#5

Now I get:

Код:
warning 217: loose indentation
error 029: invalid expression, assumed zero
error 004: function "OnPlayerExitVehicle" is not implemented
warning 225: unreachable code
error 029: invalid expression, assumed zero
error 017: undefined symbol "destroyhydra"
warning 219: local variable "ahydra" shadows a variable at a preceding level
Its a real difficult script, doing anything with it is a head fuck and a half -_-





EDIT: Eh, fuck it. I give up on it, I've been trying to way too long just to do this. Thanks a lot for the help anyway.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)