SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/02/2014, 03:34 PM   #1
[FAT]Klabauter[LST]
Big Clucker
 
[FAT]Klabauter[LST]'s Avatar
 
Join Date: Jul 2011
Posts: 73
Reputation: 17
Default OnPlayerWeaponShot help

Hi, I'm trying to make a weapon stats script that counts a shot on an empty vehicle as a miss, but counts a shot on an occupied vehicle as a hit. The script (below) is counting both empty and occupied vehicle shots as misses and I'm stuck

PHP Code:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    if(!
IsPlayerConnected(playerid)) return 0;
    
shots[playerid] ++;
    if(
hittype == BULLET_HIT_TYPE_NONE
    
|| hittype == BULLET_HIT_TYPE_OBJECT
    
|| hittype == BULLET_HIT_TYPE_PLAYER_OBJECT)
    {
        
misses[playerid] ++;
    }
    if(
hittype == BULLET_HIT_TYPE_PLAYER)
    {
        
phits[playerid] ++;
    }
    if(
hittype == BULLET_HIT_TYPE_VEHICLE)
    {
        if(
VehicleOccupied(hitid))
        {
            
vhits[playerid] ++;
        }
        else
        {
            
misses[playerid] ++;
        }
    }
    return 
1;
}

stock VehicleOccupied(vehicleid)
{
    foreach (new 
Player)
    {
        if(
IsPlayerInVehicle(i,vehicleid)) return 1;
    }
    return 
0;

I appreciate any help thanks
__________________


Exploding Bullets for Country Rifle
http://forum.sa-mp.com/showthread.ph...loding+bullets

Aimbot Detection
http://forum.sa-mp.com/showthread.ph...47#post2887047
[FAT]Klabauter[LST] is offline   Reply With Quote
Old 17/02/2014, 04:09 PM   #2
phoon
Little Clucker
 
Join Date: Feb 2014
Location: Pakistan, Quetta.
Posts: 37
Reputation: 0
Default Re: OnPlayerWeaponShot help

What are you saying? I don't understand.
You want that shots on empty vehicle should count as hit or miss?
__________________
The hard you work, the best result you get.
phoon is offline   Reply With Quote
Old 17/02/2014, 04:11 PM   #3
[FAT]Klabauter[LST]
Big Clucker
 
[FAT]Klabauter[LST]'s Avatar
 
Join Date: Jul 2011
Posts: 73
Reputation: 17
Default Re: OnPlayerWeaponShot help

Quote:
Originally Posted by phoon View Post
What are you saying? I don't understand.
You want that shots on empty vehicle should count as hit or miss?
empty = miss, occupied = hit
__________________


Exploding Bullets for Country Rifle
http://forum.sa-mp.com/showthread.ph...loding+bullets

Aimbot Detection
http://forum.sa-mp.com/showthread.ph...47#post2887047

Last edited by [FAT]Klabauter[LST]; 17/02/2014 at 06:29 PM.
[FAT]Klabauter[LST] is offline   Reply With Quote
Old 19/07/2014, 09:09 PM   #4
XXJacksug8X
Little Clucker
 
XXJacksug8X's Avatar
 
Join Date: Jan 2014
Location: here :P. i script for 4 other servers and i sell my scripts FREE/low cost! u can also order a script
Posts: 24
Reputation: 0
Default Re: OnPlayerWeaponShot help

Code:
//what you asked for, only "counts a shot on an empty vehicle as a miss, but counts a shot on an occupied vehicle as a hit"
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) 
{
	shots[playerid] ++;
    if(hittype == BULLET_HIT_TYPE_VEHICLE) 
    { 
        if(VehicleOccupied(hitid)) vhits[playerid] ++; 
        else misses[playerid] ++; 
    } 
    return 1; 
} 

//what i find more logic: counts a shot on a player or occupied vehicle as a hit and counts a shot anywhere else as a miss
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) 
{
	shots[playerid] ++;
	if (
		(hittype == BULLET_HIT_TYPE_PLAYER && hitid != playerid) ||
		(hittype == BULLET_HIT_TYPE_VEHICLE && VehicleOccupied(hitid))
	)
		vhits[playerid]++; else misses[playerid] ++;
    return 1; 
} 



//this function is called about 10 times as frequently as a fire rate, depending on the number of players shooting together. with the bool tag u use 4 times less space (from 4 bytes/return to 1 byte/return)
bool:VehicleOccupied(vehicleid) 
{ 
    foreach (new i : Player) if(IsPlayerInVehicle(i,vehicleid)) return true;
    return false; 
}
__________________
Wingsuit / Xtreme B.A.S.E Jump / Race / Drift / Stunt / Parkour / FFA / DM / CTF / WS / WSA
[0.3z-R2] >>176.65.137.99:7779 <<[V5.94] [0.3z-R2] >> 176.65.137.99:7779 << [V5.94]
XXJacksug8X 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
OnPlayerWeaponShot bug FRIK Scripting Help 1 14/02/2014 06:01 AM
SA-MP 0.3z OnPlayerWeaponShot Admigo Screenshots and Videos 5 19/01/2014 09:01 PM
BUG in OnPlayerWeaponShot Spooke Scripting Help 5 19/01/2014 10:45 AM
[BUG ?] fX, fY, fZ in OnPlayerWeaponShot newbienoob Scripting Help 5 18/01/2014 01:36 PM
[BUG] OnPlayerWeaponShot + ... White_116 Scripting Help 0 17/01/2014 06:06 PM


All times are GMT. The time now is 12:25 AM.


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