SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 14/07/2014, 09:26 PM   #1
JessThompson
Huge Clucker
 
JessThompson's Avatar
 
Join Date: Dec 2013
Location: Developer Lodge
Posts: 413
Reputation: 22
Default Help with weapon damage system thanks

pawn Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
        new Float:HP;
    GetPlayerHealth(playerid, HP);
    if(issuerid != INVALID_PLAYER_ID)
    {
                switch(weaponid)
                {
                    case 22:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-13); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-8); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-26); // Head
                                }
                        }
                    case 23:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-15); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-12); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-25); // Head
                                }
                        }
                    case 24:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-23); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-20); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-15); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-15); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-15); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-15); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-67); // Head
                                }
                        }
                    case 25:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-30); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-27); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-23); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-23); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-22); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-22); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-70); // Head
                                }
                        }
                    case 27:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-20); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-14); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-10); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-10); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-9); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-9); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-70); // Head
                                }
                        }
                    case 28:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-10); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-8); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-20); // Head
                                }
                        }
                    case 29:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-10); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-8); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-20); // Head
                                }
                        }
                    case 30:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-21); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-14); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-9); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-9); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-8); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-8); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-40); // Head
                                }
                        }
                    case 31:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-21); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-14); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-9); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-9); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-8); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-8); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-40); // Head
                                }
                        }
                    case 32:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-10); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-8); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-5); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-5); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-5); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-5); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-20); // Head
                                }
                        }
                    case 33:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-26); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-15); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-10); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-14); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-10); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-14); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-40); // Head
                                }
                        }
                    case 34:
                        {
                            switch(bodypart)
                                {
                                        case 3: SetPlayerHealth(playerid, HP-33); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-28); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-20); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-20); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-20); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-20); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-100); // Head
                                }
                        }
                }
    }
    return 1;
}



How could i make this so it checks if you have armour and the takes it off armour but if you don't have armour it takes it from health. +rep
JessThompson is offline   Reply With Quote
Old 14/07/2014, 09:45 PM   #2
JessThompson
Huge Clucker
 
JessThompson's Avatar
 
Join Date: Dec 2013
Location: Developer Lodge
Posts: 413
Reputation: 22
Default Re: Help with weapon damage system thanks

Anyone please?
JessThompson is offline   Reply With Quote
Old 14/07/2014, 10:07 PM   #3
Don_Cage
High-roller
 
Don_Cage's Avatar
 
Join Date: Aug 2012
Posts: 1,100
Reputation: 40
Default Re: Help with weapon damage system thanks

pawn Code:
new armour;//defines the armour var..
GetPlayerArmour(playerid, armour);//Get the players armour
if(armour >= x)//Check if the armour is above a certain ammount (change the x.)
SetPlayerArmour(playerid, armour-ammount);//If the armour is higher than the ammount you checked, decrease it with the ammount you like..

//If the armour check is not higher, take the ammount form the health
Don_Cage is offline   Reply With Quote
Old 14/07/2014, 10:25 PM   #4
JessThompson
Huge Clucker
 
JessThompson's Avatar
 
Join Date: Dec 2013
Location: Developer Lodge
Posts: 413
Reputation: 22
Default Re: Help with weapon damage system thanks

So would this work

pawn Code:
case 3: if(armour >= 0)
                    SetPlayerArmour(playerid, armour-10);
                    else SetPlayerHealth(playerid, HP-33); // Torso
                                        case 4: SetPlayerHealth(playerid, HP-28); // Groin
                                        case 5: SetPlayerHealth(playerid, HP-20); // Left ARM
                                        case 6: SetPlayerHealth(playerid, HP-20); // Right ARM
                                        case 7: SetPlayerHealth(playerid, HP-20); // Left Leg
                                        case 8: SetPlayerHealth(playerid, HP-20); // Right Leg
                                        case 9: SetPlayerHealth(playerid, HP-100); // Head
JessThompson is offline   Reply With Quote
Old 14/07/2014, 11:16 PM   #5
azzerking
Gangsta
 
azzerking's Avatar
 
Join Date: Dec 2009
Location: England, Leicestershire
Posts: 488
Reputation: 70
Default Re: Help with weapon damage system thanks

The best way to do that is to check if the player armour is more then the you want to take off.

For example:

Your armour is: 30
Your health is 100
Your damage: 40

You first check to see if you have more armour then damage, if you have less then you get the player armour and take it away from the damage and then apply the remaining damage to health.

pawn Code:
new float:hp, float:armor;
GetPlayerHealth(playerid, hp);
GetPlayerArmor(playerid, armour);

if(armour > amount)
{
      armour - amount;
      SetPlayerArmor(playerid, armour);
}
else if(armour >= 0 && armour < amount)
{
      amount - armour;
      SetPlayerHealth(playerid, HP - amount);
}

This is untested but should work, unless I have missed something. If anyone finds anything wrong. Fell free to correct it.
__________________


Web Skill: PHP, HTML, CSS, JS, RUBY, NODE.js.

Programing Skill: Objective C, C#, C++, D#, Python, Java, MySQL.

OS Skill: Windows (95 - 10), Ubuntu/Debian, Raspbian, Kali, Arch, Unix, Mac (E-MACs - Current)

Scripting Skill: LUA, Pawn, C38*
azzerking is offline   Reply With Quote
Old 15/07/2014, 12:56 PM   #6
JessThompson
Huge Clucker
 
JessThompson's Avatar
 
Join Date: Dec 2013
Location: Developer Lodge
Posts: 413
Reputation: 22
Default Re: Help with weapon damage system thanks

could you please link that up to the case because i need it to be linked up to the bodyparts thanks
JessThompson is offline   Reply With Quote
Old 15/07/2014, 01:18 PM   #7
JessThompson
Huge Clucker
 
JessThompson's Avatar
 
Join Date: Dec 2013
Location: Developer Lodge
Posts: 413
Reputation: 22
Default Re: Help with weapon damage system thanks

Well could you help me link it up to the damage system please +rep
JessThompson is offline   Reply With Quote
Old 15/07/2014, 02:01 PM   #8
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,191
Reputation: 1241
Default Re: Help with weapon damage system thanks

You should just throw away all the code you have right now because it's all junk and is not how this kind of system should work. You need to use OnPlayerGiveDamage() the new lag compensation system isn't very reliable so it requires a helper system of course in doing this you can do a lot of other things such as specific damage amounts and completely server sided damage. In my opinion OnPlayerTakeDamage() is obsolete with lag comp enabled as there is significant missed shots when clearly the skin has been shot. We identified this issue very early on and you will see here on this server dedi.slice-vps.nl:8888 "Anti-lag enabled" in the bottom right corner.
Pottus 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
[FilterScript] New Weapon Damage System [0.3z] RenSoprano Filterscripts 6 17/01/2014 07:03 AM
[FilterScript] Weapon damage system [v1.0] Darnell Filterscripts 74 21/10/2013 09:53 PM
[FilterScript] Weapon Damage System Donicans Filterscripts 14 06/11/2012 02:22 PM
[FilterScript] Realistic Weapon Damage And Death System [V1.0][New Cool FS] Nirzor Filterscripts 6 08/08/2012 06:34 AM
Weapon damage!! BlackWolf120 Help Archive 4 13/03/2011 01:27 AM


All times are GMT. The time now is 08:26 AM.


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