SA-MP Forums Archive
Problem when a player dies in a vehicle (+1 REP) - 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)
+--- Thread: Problem when a player dies in a vehicle (+1 REP) (/showthread.php?tid=605968)



Problem when a player dies in a vehicle (+1 REP) - ChristolisTV - 27.04.2016

I am trying to create a derby gamemode but I have some errors that I can't fix! I want if a player kills another player and both are in a vehicle the killer will hear some sound and will recieve a client message. Any help please? I tried to create something but unluckily doesn't work.

PHP код:
public OnVehicleDeath(vehicleidkillerid)
{
    new 
pVictim[MAX_PLAYER_NAME];
       
GetPlayerName(vehicleid,pVictim,sizeof(pVictim));
        
PlayerPlaySound(killerid11490.00.00.0);
    
DestroyVehicle(vehicleid);
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    
SendClientMessage(killerid, -1"{FF6000}[Congratulations]:{FFFFFF} You killed someone!");
    
GameTextForPlayer(playerid"~r~ DEAD!",20003);
        
PlayerPlaySound(killerid11490.00.00.0);
    return 
1;

And don't forget the REP!


Re: Problem when a player dies in a vehicle (+1 REP) - BloodyRP - 27.04.2016

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(IsPlayerInAnyVehicle(playerid) && IsPlayerInAnyVehicle(killerid)
    {
    	SendClientMessage(killerid, -1, "{FF6000}[Congratulations]:{FFFFFF} You killed someone!");
    	GameTextForPlayer(playerid, "~r~ DEAD!",2000, 3);
        PlayerPlaySound(killerid, 1149, 0.0, 0.0, 0.0);
    }
    return true;
}



Re: Problem when a player dies in a vehicle (+1 REP) - xTURBOx - 27.04.2016

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
IsPlayerInAnyVehicle(playerid) && IsPlayerInAnyVehicle(killerid))
    {
        
SendClientMessage(killerid, -1"{FF6000}[Congratulations]:{FFFFFF} You killed someone!");
        
GameTextForPlayer(playerid"~r~ DEAD!",20003);
        
PlayerPlaySound(killerid11490.00.00.0);
    }
    return 
1;

@BloodyRP
i just fixed few problems with your code


Re: Problem when a player dies in a vehicle (+1 REP) - BloodyRP - 27.04.2016

Quote:
Originally Posted by xTURBOx
Посмотреть сообщение
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    if(
IsPlayerInAnyVehicle(playerid) && IsPlayerInAnyVehicle(killerid))
    {
        
SendClientMessage(killerid, -1"{FF6000}[Congratulations]:{FFFFFF} You killed someone!");
        
GameTextForPlayer(playerid"~r~ DEAD!",20003);
        
PlayerPlaySound(killerid11490.00.00.0);
    }
    return 
1;

@BloodyRP
i just fixed few problems with your code
oh, forgot "any" xD, thanks.


Re: Problem when a player dies in a vehicle (+1 REP) - Ritzy2K - 27.04.2016

If you want that both are in vehicle, just add a conditional statement which checks both are in vehicle before sending them messages and gametext?


Re: Problem when a player dies in a vehicle (+1 REP) - ChristolisTV - 27.04.2016

Quote:
Originally Posted by BloodyRP
Посмотреть сообщение
oh, forgot "any" xD, thanks.
@BloodyRP

I want when I kill someone with drive-by. And exploding his car not killing him.


Re: Problem when a player dies in a vehicle (+1 REP) - BloodyRP - 27.04.2016

Quote:
Originally Posted by ChristolisTV
Посмотреть сообщение
@BloodyRP

I want when I kill someone with drive-by. And exploding his car not killing him.
Quote:
Originally Posted by ChristolisTV
Посмотреть сообщение
I want if a player kills another player and both are in a vehicle the killer will hear some sound and will recieve a client message
Cant understand how u want to kill drive-by when both in a vehicles, but okay:

PHP код:
public OnPlayerDeath(playerid,killerid,reason)
{
    if(
killerid != INVALID_PLAYER_ID)
    {
        if(
GetPlayerState(killerid) == PLAYER_STATE_DRIVER)
        {
            
SendClientMessage(killerid, -1"{FF6000}[Congratulations]:{FFFFFF} You killed someone!");
            
GameTextForPlayer(playerid"~r~ DEAD!",20003);
            
PlayerPlaySound(killerid11490.00.00.0);
            if(
IsPlayerInAnyVehicle(playerid)) DestroyVehicle(GetPlayerVehicleID(playerid));
        }
    }
    return 
true;