SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 20/03/2020, 10:19 PM   #1
Ejected
Big Clucker
 
Ejected's Avatar
 
Join Date: Jul 2012
Location: United States Discord: ABC#6701
Posts: 184
Reputation: 18
Default OnPlayerTakeDamage damage is very laggy

Is there a good way to optimize OnPlayerTakeDamage to make it less laggy?


https://www.youtube.com/watch?v=oueub2kT2GA

All of the code is in this format for each gun I only pasted weaponid 0 but it goes all the way up to weaponid 34:

PHP Code:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    new 
Floathealth;
    new 
Floatarmour;
    
GetPlayerHealth(playeridhealth);
    
GetPlayerArmour(playeridarmour);
    
//
    
if (PlayerData[playerid][pFirstAid])
    {
        
SendClientMessage(playeridCOLOR_LIGHTRED"[WARNING]:{FFFFFF} Your first aid kit is no longer in effect as you took damage.");

        
PlayerData[playerid][pFirstAid] = 0;
        
KillTimer(PlayerData[playerid][pAidTimer]);
    }
    
//
    
if(issuerid != INVALID_PLAYER_ID)
    {
        if(
weaponid == 0)
        {
            switch(
armour)
            {
                case 
0:
                {
                    switch(
bodypart)
                    {
                        case 
3SetPlayerHealth(playeridhealth 5); // Torso.
                        
case 4SetPlayerHealth(playeridhealth 5); // Groin.
                        
case 5SetPlayerHealth(playeridhealth 5);  // Left Arm.
                        
case 6SetPlayerHealth(playeridhealth 5); // Right Arm.
                        
case 7SetPlayerHealth(playeridhealth 5);  // Left Leg.
                        
case 8SetPlayerHealth(playeridhealth 5); // Right Leg.
                        
case 9SetPlayerHealth(playeridhealth 5); // Head.
                    
}
                }
                default:
                {
                    switch(
bodypart)
                    {
                        case 
3SetPlayerHealth(playeridhealth 5); // Torso.
                        
case 4SetPlayerHealth(playeridhealth 5); // Groin.
                        
case 5SetPlayerHealth(playeridhealth 5);  // Left Arm.
                        
case 6SetPlayerHealth(playeridhealth 5); // Right Arm.
                        
case 7SetPlayerHealth(playeridhealth 5);  // Left Leg.
                        
case 8SetPlayerHealth(playeridhealth 5); // Right Leg.
                        
case 9SetPlayerHealth(playeridhealth 5); // Head.
                    
}
                }
            }
        } 
Ejected is offline   Reply With Quote
Old 20/03/2020, 10:22 PM   #2
Ejected
Big Clucker
 
Ejected's Avatar
 
Join Date: Jul 2012
Location: United States Discord: ABC#6701
Posts: 184
Reputation: 18
Default Re: OnPlayerTakeDamage damage is very laggy

Would something like this for each "case" help?

PHP Code:
case 3: return SetPlayerHealth(playerid,... ect ect
Ejected is offline   Reply With Quote
Old 24/03/2020, 03:39 PM   #3
Ejected
Big Clucker
 
Ejected's Avatar
 
Join Date: Jul 2012
Location: United States Discord: ABC#6701
Posts: 184
Reputation: 18
Default Re: OnPlayerTakeDamage damage is very laggy

Bump
__________________
Ejected 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
Help set 0 damage onplayertakedamage gmstrikker Scripting Help 3 25/09/2015 08:17 AM
Custom damage problem - OnPlayerTakeDamage Chipardeur Scripting Help 6 28/12/2014 01:13 AM
Triangle.gs Laggy? Rocky Racoon Everything and Nothing 10 22/12/2014 06:30 PM
Youtube being laggy? Coltmaster Everything and Nothing 2 11/04/2013 09:28 PM
How to take less damage using OnPlayerTakeDamage? Marricio Scripting Help 5 13/03/2012 06:42 PM


All times are GMT. The time now is 03:15 AM.


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