Vice City: Multiplayer

VC:MP Discussion => General Discussion => Topic started by: Anik on Oct 12, 2016, 08:53 AM

Title: Event when any player is shot by another player
Post by: Anik on Oct 12, 2016, 08:53 AM
What about adding an event which will be called  when any player is shot by another player. I want it to prevent HP Hacks. Like Player1 shot Player2 but it didn't cause any damage to him. But he doesn't have any immunity or GodMode. So in order to prevent this we can do this by ourselves if the event is added. So it will be like this

onPlayerShot( player, Shotby, oldHP, newHP, oldArmor, newArmor )
And it will be more helpful if also weapon and body part is added. Like

onPlayerShot( player, Shotby, oldHP, newHP, oldArmor, newArmor, wep, bodypart )
Title: Re: Event when any player is shot by another player
Post by: vito on Oct 12, 2016, 09:18 AM
It's already in client side. And this is not working with FPV.
Title: Re: Event when any player is shot by another player
Post by: Anik on Oct 12, 2016, 09:33 AM
Quote from: vito on Oct 12, 2016, 09:18 AMIt's already in client side. And this is not working with FPV.
But by whom it has been shot is not added. And also the HP and armour thingy.......
Title: Re: Event when any player is shot by another player
Post by: Xmair on Oct 12, 2016, 02:39 PM
I suggest you to read this again. http://forum.vc-mp.org/?topic=2719.msg20159#msg20159
Title: Re: Event when any player is shot by another player
Post by: KAKAN on Oct 13, 2016, 05:37 AM
Quote from: Xmair on Oct 12, 2016, 02:39 PMI suggest you to read this again. http://forum.vc-mp.org/?topic=2719.msg20159#msg20159
Player::PlayerShoot(player, weapon, hitEntity, hitPosition)
It's there in the first spoiler. Check the type of hitEntity, if its an instance, send a stream to the server :D
Title: Re: Event when any player is shot by another player
Post by: Anik on Oct 13, 2016, 08:47 AM
Quote from: KAKAN on Oct 13, 2016, 05:37 AM
Quote from: Xmair on Oct 12, 2016, 02:39 PMI suggest you to read this again. http://forum.vc-mp.org/?topic=2719.msg20159#msg20159
Player::PlayerShoot(player, weapon, hitEntity, hitPosition)
It's there in the first spoiler. Check the type of hitEntity, if its an instance, send a stream to the server :D
That's okay but I want the oldHP and newHP. So that i can check if hp has decreased or not after shot.

 :edit: also it doesnt work for some weps like stubby, sniper. :/
Title: Re: Event when any player is shot by another player
Post by: vito on Oct 13, 2016, 10:48 AM
btw, use this checking only if hitPosition is "local player".
Title: Re: Event when any player is shot by another player
Post by: Anik on Oct 13, 2016, 11:17 AM
Quote from: vito on Oct 13, 2016, 10:48 AMbtw, use this checking only if hitPosition is "local player".
hitPosition returns VECTOR position.
Title: Re: Event when any player is shot by another player
Post by: vito on Oct 13, 2016, 12:54 PM
hitEntity, yep, sorry.
Title: Re: Event when any player is shot by another player
Post by: NicusorN5 on Oct 13, 2016, 03:30 PM
QuotePlayer::PlayerShoot(player, weapon, hitEntity, hitPosition)
Parameter types: Player, int, entity, Vector. Return type: void.
Called when a player makes a shot. If something was hit, hitEntity points to that and hitPosition is the position of the collision. Otherwise, hitEntity is null and hitPosition is the end of the bullet trajectory.
-_-
Title: Re: Event when any player is shot by another player
Post by: Mötley on Oct 14, 2016, 12:08 AM
Maybe....
function onPlayerKill( Shotby, player, reason, bodypart )
{
   //Maybe you should store the players health/Armor in a timed array
    local oldHP = ...
    local newHP = ...
    local oldArmor = ...
    local newArmor = ...
    onPlayerShot( player, Shotby, oldHP, newHP, oldArmor, newArmor )

    return true;
}

function onPlayerShot( player, Shotby, oldHP, newHP, oldArmor, newArmor )
{
   /*Do It*/
   print("Did you do it?");

    return true;
}
Title: Re: Event when any player is shot by another player
Post by: Xmair on Oct 14, 2016, 09:03 AM
Quote from: Mötley on Oct 14, 2016, 12:08 AMMaybe....
function onPlayerKill( Shotby, player, reason, bodypart )
{
   //Maybe you should store the players health/Armor in a timed array
    local oldHP = ...
    local newHP = ...
    local oldArmor = ...
    local newArmor = ...
    onPlayerShot( player, Shotby, oldHP, newHP, oldArmor, newArmor )

    return true;
}

function onPlayerShot( player, Shotby, oldHP, newHP, oldArmor, newArmor )
{
   /*Do It*/
   print("Did you do it?");

    return true;
}
onPlayerKill is called when a player is killed by another player not shot.
Title: Re: Event when any player is shot by another player
Post by: Anik on Oct 14, 2016, 11:09 AM
What about if only CPlayer.LastHp and CPlayer.LastArmor is added?
Then we can compare between lasthp and current hp of the player.
Title: Re: Event when any player is shot by another player
Post by: KAKAN on Oct 14, 2016, 11:46 AM
Quote from: Anik on Oct 14, 2016, 11:09 AMWhat about if only CPlayer.LastHp and CPlayer.LastArmor is added?
Then we can compare between lasthp and current hp of the player.
Most shitty suggestion ever. You can do it pretty easily though
Title: Re: Event when any player is shot by another player
Post by: Anik on Oct 14, 2016, 12:33 PM
Quote from: KAKAN on Oct 14, 2016, 11:46 AM
Quote from: Anik on Oct 14, 2016, 11:09 AMWhat about if only CPlayer.LastHp and CPlayer.LastArmor is added?
Then we can compare between lasthp and current hp of the player.
Most shitty suggestion ever. You can do it pretty easily though
Show example
Title: Re: Event when any player is shot by another player
Post by: Mötley on Oct 14, 2016, 12:45 PM
@Xmair, I told him to store the players health in a array while on the server..... I know this..
The Killer with God mode might still get away.

function onPlayerUpdate() if it exist in vcmp would help with this.

Either way if there were a onPlayerShot/ onClientShot function then it would be similar to

http://forum.liberty-unleashed.co.uk/index.php/topic,2070.0.html
Title: Re: Event when any player is shot by another player
Post by: DizzasTeR on Oct 14, 2016, 01:37 PM
local lastDamage = null;

function Player::PlayerShoot(player, weapon, hitEntity, hitPosition) {
    if( hitEntity && hitEntity == OBJ_PLAYER ) {
        local damaged_player = hitEntity;
        local shooting_player = player;
       
        if( !lastDamage ) {
            lastDamage = { Name = damaged_player.Name, HP = damaged_player.Health };
        }
        else {
            if( damaged_player.Name == lastDamage.Name && damaged_player.Health >= lastDamage.HP ) {
                // Same HP after getting shot
            }
        }
    }
}

Untested, and I just coded this to give you an idea how it can be done on client-side.