SA-MP Forums Archive
OnPlayerVehicleDeath Problams.. - 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: OnPlayerVehicleDeath Problams.. (/showthread.php?tid=147437)



OnPlayerVehicleDeath Problams.. - Lorenc_ - 12.05.2010

Hey everyone I've got a problam... When my vehicle is on its death it explodes everyone and set everyones health...

heres my code..

Код:
public OnVehicleDeath(vehicleid, killerid)
{
 for(new i = 0; i < MAX_PLAYERS; i++)
	{
		new Float:x, Float:y, Float:z;
		SetPlayerHealth(i, 0.0);
		DestroyVehicle(vehicleid);
		GetPlayerPos(i,x, y, z);
		CreateExplosion(x, y , z, 0, 10);
	}
	return 1;
}
Would this work?

Код:
public OnVehicleDeath(vehicleid, killerid)
{
	new Float:x, Float:y, Float:z;
	SetPlayerHealth(killerid, 0.0);
	DestroyVehicle(vehicleid);
	GetPlayerPos(killerid,x, y, z);
	CreateExplosion(x, y , z, 0, 10);
	return 1;
}
are my loops fucked please help..



Re: OnPlayerVehicleDeath Problams.. - [MWR]Blood - 12.05.2010

pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
 
        new Float:x, Float:y, Float:z;
        SetPlayerHealth(playerid, 0.0);
        DestroyVehicle(vehicleid);
        GetPlayerPos(playerid,x, y, z);
        CreateExplosion(x, y , z, 0, 10);
    }
    return 1;
}



Re: OnPlayerVehicleDeath Problams.. - mamorunl - 12.05.2010

Quote:
Originally Posted by ikarus❶❸❸❼
pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
 
        new Float:x, Float:y, Float:z;
        SetPlayerHealth(playerid, 0.0);
        DestroyVehicle(vehicleid);
        GetPlayerPos(playerid,x, y, z);
        CreateExplosion(x, y , z, 0, 10);
    }
    return 1;
}
Not working. There is no playerid in the parameters for the function.

If you only want yourself to blow up, you can just get into the car? You could try with the 'killerid' to blow up or go with a playerToPoint() check to see if your player is near the car. Getting the playerid itself, however, is not possible since OnVehicleDeath() does not have a parameter 'playerid'.

Greetings!

ps. Just adding 'playerid' in there is not going to work. It will just get id 0


Re: OnPlayerVehicleDeath Problams.. - Lorenc_ - 12.05.2010

Quote:
Originally Posted by ikarus❶❸❸❼
pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
 
        new Float:x, Float:y, Float:z;
        SetPlayerHealth(playerid, 0.0);
        DestroyVehicle(vehicleid);
        GetPlayerPos(playerid,x, y, z);
        CreateExplosion(x, y , z, 0, 10);
    }
    return 1;
}
fail code


Re: OnPlayerVehicleDeath Problams.. - nakashor - 12.05.2010

pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
 for(new i = 0; i < MAX_PLAYERS; i++)
    {
       if(GetPlayerVehicleID(i) == vehicleid)
       {
        new Float:x, Float:y, Float:z;
        SetPlayerHealth(i, 0.0);
        DestroyVehicle(vehicleid);
        GetPlayerPos(i,x, y, z);
        CreateExplosion(x, y , z, 0, 10);
       }
    }
    return 1;
}
Untested.


Re: OnPlayerVehicleDeath Problams.. - Lorenc_ - 12.05.2010

Quote:
Originally Posted by Teddy™
pawn Код:
public OnVehicleDeath(vehicleid, killerid)
{
 for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if(GetPlayerVehicleID(i) == vehicleid)
      {
        new Float:x, Float:y, Float:z;
        SetPlayerHealth(i, 0.0);
        DestroyVehicle(vehicleid);
        GetPlayerPos(i,x, y, z);
        CreateExplosion(x, y , z, 0, 10);
      }
    }
    return 1;
}
Untested.
Hmm i wont bother with that code because loops makes all the players explode and die


Re: OnPlayerVehicleDeath Problams.. - CuervO - 13.05.2010

Read the code providen by Teddy carefully, it checks thru all players if they are driving the car that died, if yes, then explode the driver of the player. Never used onvehicledead but it should work


Re: OnPlayerVehicleDeath Problams.. - Lorenc_ - 13.05.2010

Quote:
Originally Posted by CueЯvo
Read the code providen by Teddy carefully, it checks thru all players if they are driving the car that died, if yes, then explode the driver of the player. Never used onvehicledead but it should work
Ohh i thought it was my code ill check it after .