SA-MP Forums

Go Back   SA-MP Forums > SA-MP > Bug Reports

Reply
 
Thread Tools Display Modes
Old 11/01/2018, 07:27 PM   #1
IstuntmanI
High-roller
 
IstuntmanI's Avatar
 
Join Date: Mar 2009
Location: Romania
Posts: 1,862
Reputation: 370
Default OnPlayerWeaponShot when shooting a driver/passenger

If you are on foot and you shoot a driver/passenger in a vehicle (and damaging him) OnPlayerWeaponShot will only be called with hittype = BULLET_HIT_TYPE_VEHICLE with the hitid = player's vehicleid. The vehicle isn't actually shot at all and it isn't receiving damage and the driver/passenger is actually getting damage. In the "worst case" OnPlayerWeaponShot should be called twice: once for the vehicle and once for the damaged player.

I tried to find if this was already reported, but only the one about driveby-ing without calling the callback was reported.
__________________



Last edited by IstuntmanI; 11/01/2018 at 09:07 PM.
IstuntmanI is offline   Reply With Quote
Old 20/01/2018, 04:32 PM   #2
Paglia
Little Clucker
 
Join Date: Jul 2013
Posts: 17
Reputation: 0
Lightbulb Re: OnPlayerWeaponShot when shooting a driver/passenger

I don't know if this will be of much help but it may be somewhat related to this issue.

When a player is on foot, then CPlayer* points to the player itself. However, when a player is on a vehicle, CPlayer* points to the vehicle the player is driving.

I suspect that this goes on in samp too, and that's why the hittype is BULLET_HIT_TYPE_VEHICLE and the hitid = player's vehicleid.

(Guess as to what happens below)
The game checks for the CPlayer * directly to see what the player id's is (keep in mind that in samp the player pointer points to the first element, the id) to see what the player id is, and since that player is in a vehicle, then the hitid becomes that vehicle's id, and therefore the type is assigned BULLET_HIT_TYPE_VEHICLE.

(A possible fix?)
In that part of the code where the callback is evaluated, there should be some check to see if the dereferenced CPlayer* points to the actual player in question. Perhaps this can be done by checking one of the "unique" members for each "object" and to determine that way if the dereferenced object in question is either a car or a player.

I apologize for my confusing input, but this hopefully gives idea on how to go in the right direction to solve this.
Paglia is offline   Reply With Quote
Old 22/01/2018, 12:17 AM   #3
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,806
Reputation: 831
Default Re: OnPlayerWeaponShot when shooting a driver/passenger

This actually might mess up libraries using OnPlayerWeaponShot, specifically anticheats.
__________________

My GitHub:

Gammix is offline   Reply With Quote
Old 22/01/2018, 09:35 AM   #4
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,144
Reputation: 345
Default Re: OnPlayerWeaponShot when shooting a driver/passenger

Quote:
Originally Posted by Gammix View Post
This actually might mess up libraries using OnPlayerWeaponShot, specifically anticheats.
You can check for hittype 2 and loop through all players if GetPlayerVehicleID(i) = hitid (hitid = vehicle id that was hit) (i = the player picked out the loop) then set a variable to mark that the player riding this vehicle got his vehicle shot and never use it in any other way because what he stated above will fuck it, so you need to detect shots shot for players driving under hittype 2 and a loop, then detect shots shot only for onfoot players (separating them via using GetPlayerState) not sure if u understand me but i used that on my in-process anti gm i'll release soon and i didnt get false positive for the matter that was stated above.
__________________
Quote:
I'm not using the forum to release stuff anymore, if you want updates for my releases or to check my new releases check the links below >
Quote:
Originally Posted by Escobar ⚠
Life sucked me in and shat me on the cruel world.

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link



Last edited by RogueDrifter; 22/01/2018 at 10:08 AM.
RogueDrifter is offline   Reply With Quote
Old 26/01/2018, 10:13 PM   #5
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,806
Reputation: 831
Default Re: OnPlayerWeaponShot when shooting a driver/passenger

Quote:
Originally Posted by RogueDrifter View Post
You can check for hittype 2 and loop through all players if GetPlayerVehicleID(i) = hitid (hitid = vehicle id that was hit) (i = the player picked out the loop) then set a variable to mark that the player riding this vehicle got his vehicle shot and never use it in any other way because what he stated above will fuck it, so you need to detect shots shot for players driving under hittype 2 and a loop, then detect shots shot only for onfoot players (separating them via using GetPlayerState) not sure if u understand me but i used that on my in-process anti gm i'll release soon and i didnt get false positive for the matter that was stated above.
__________________

My GitHub:

Gammix is offline   Reply With Quote
Old 27/01/2018, 01:00 PM   #6
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,144
Reputation: 345
Default Re: OnPlayerWeaponShot when shooting a driver/passenger

Quote:
Originally Posted by Gammix View Post
lmao, what i meant was, his problem is when a player is shot in a vehicle only hittype 2 is called, so what i was saying is why's that a problem when you can loop on hittype 2 for the driver of hitid (vehicle id) right? like this:
PHP Code:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    switch(
hittype)
    {
        case 
1:
        {
            if(
GetPlayerState(playerid) == 1)
            {
                
//player hit on foot.
                
}
            }
        case 
2:
        {
            for(new 
iGetPlayerPoolSize(); <= ji++)
            {
                if(!
IsPlayerConnected(i) || GetPlayerState(i) == 1) continue;
                if(
GetPlayerVehicleID(i) == hitid && GetPlayerState(i) ==2)
                {
                    
//driver of the vehicle that was hit by another player is 'i'
                    
}
                if(
GetPlayerVehicleID(i) == hitid && GetPlayerState(i) ==3)
                {
                    
//passenger of the vehicle shot
                    
}
                }
            }
        }
    return 
1;

__________________
Quote:
I'm not using the forum to release stuff anymore, if you want updates for my releases or to check my new releases check the links below >
Quote:
Originally Posted by Escobar ⚠
Life sucked me in and shat me on the cruel world.

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link


RogueDrifter is offline   Reply With Quote
Old 27/01/2018, 04:03 PM   #7
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,806
Reputation: 831
Default Re: OnPlayerWeaponShot when shooting a driver/passenger

Quote:
Originally Posted by RogueDrifter View Post
lmao, what i meant was, his problem is when a player is shot in a vehicle only hittype 2 is called, so what i was saying is why's that a problem when you can loop on hittype 2 for the driver of hitid (vehicle id) right? like this:
PHP Code:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    switch(
hittype)
    {
        case 
1:
        {
            if(
GetPlayerState(playerid) == 1)
            {
                
//player hit on foot.
                
}
            }
        case 
2:
        {
            for(new 
iGetPlayerPoolSize(); <= ji++)
            {
                if(!
IsPlayerConnected(i) || GetPlayerState(i) == 1) continue;
                if(
GetPlayerVehicleID(i) == hitid && GetPlayerState(i) ==2)
                {
                    
//driver of the vehicle that was hit by another player is 'i'
                    
}
                if(
GetPlayerVehicleID(i) == hitid && GetPlayerState(i) ==3)
                {
                    
//passenger of the vehicle shot
                    
}
                }
            }
        }
    return 
1;

__________________

My GitHub:

Gammix is offline   Reply With Quote
Old 27/01/2018, 04:07 PM   #8
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,144
Reputation: 345
Default Re: OnPlayerWeaponShot when shooting a driver/passenger

Quote:
Originally Posted by Gammix View Post
lol am i wrong ? ._.
__________________
Quote:
I'm not using the forum to release stuff anymore, if you want updates for my releases or to check my new releases check the links below >
Quote:
Originally Posted by Escobar ⚠
Life sucked me in and shat me on the cruel world.

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link


RogueDrifter is offline   Reply With Quote
Old 27/01/2018, 04:09 PM   #9
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,806
Reputation: 831
Default Re: OnPlayerWeaponShot when shooting a driver/passenger

Quote:
Originally Posted by RogueDrifter View Post
lol am i wrong ? ._.
__________________

My GitHub:

Gammix is offline   Reply With Quote
Old 27/01/2018, 04:12 PM   #10
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,144
Reputation: 345
Default Re: OnPlayerWeaponShot when shooting a driver/passenger

Quote:
Originally Posted by Gammix View Post
Jesus christ haha then what is it?
__________________
Quote:
I'm not using the forum to release stuff anymore, if you want updates for my releases or to check my new releases check the links below >
Quote:
Originally Posted by Escobar ⚠
Life sucked me in and shat me on the cruel world.

[Github]:Link [Gists]:Link [Forum]:Link [Server]:Link [Discord]:Link


RogueDrifter is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SA:MP Passenger shooting from car (By H) fix? Riwerry Scripting Help 16 06/05/2015 04:18 PM
How to show this for the driver and the passenger ? Drago987 Scripting Help 9 22/06/2014 02:44 AM
OnPlayerWeaponShot on DriveBy passenger Kyra Bug Reports 7 24/04/2014 04:39 PM
Help, Shooting from a car as passenger. Kenzix Scripting Help 5 18/03/2014 07:42 PM
Car take damage without a passenger/driver. Unri Scripting Help 4 26/09/2013 10:39 PM


All times are GMT. The time now is 07:57 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.