SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 09/04/2020, 06:37 AM   #1
Nuginity
Big Clucker
 
Nuginity's Avatar
 
Join Date: Feb 2020
Location: Indonesia (Jakarta)
Posts: 61
Reputation: 2
Default Prevent Damage

Can someone tell how to prevent damage in "OnPlayerGvieDamage" callback, i've tried this, but nothings happen
PHP Code:
public OnPlayerGiveDamage(playeriddamagedidFloat:amountweaponidbodypart)
{
    new 
Float:hamount;
    
GetPlayerHealth(damagedidhamount)
    if(
GetPVarInt(damagedid,"police") == 0)
    {
           
SetPlayerHealth(damagedidhamount+amount);
    }
    return 
1;

i've tried to search trough the forum, and i found the solutions "SetPlayerTeam" but there's anything else?
__________________
Nusantara Freeroam
Current Stage : ALPHA
-------------------------------------------
We Need an Indonesian's Scripter now!
Nuginity is offline   Reply With Quote
Old 09/04/2020, 07:34 AM   #2
ShadowMortar
Huge Clucker
 
ShadowMortar's Avatar
 
Join Date: Jul 2016
Location: Croatia
Posts: 236
Reputation: 49
Default Re: Prevent Damage

You can use
https://forum.sa-mp.com/showthread.php?t=563387
And returning 0 will automatically prevent from giving damage.
(As far as I remember)
__________________
Quote:
Originally Posted by CheezIt View Post
Follow your heart and own style.
Feel free to PM me if you need help.
Quote:
Originally Posted by Pottus View Post
That is perfectly fine, I'm just pointing out where you made mistakes what does hearing "good job" get you? Absolutely nothing. You need to hear the problems otherwise you'll keep making the same mistakes
ShadowMortar is offline   Reply With Quote
Old 09/04/2020, 07:40 AM   #3
Nuginity
Big Clucker
 
Nuginity's Avatar
 
Join Date: Feb 2020
Location: Indonesia (Jakarta)
Posts: 61
Reputation: 2
Default Re: Prevent Damage

Quote:
Originally Posted by ShadowMortar View Post
You can use
https://forum.sa-mp.com/showthread.php?t=563387
And returning 0 will automatically prevent from giving damage.
(As far as I remember)
can't use that, any solutions?
__________________
Nusantara Freeroam
Current Stage : ALPHA
-------------------------------------------
We Need an Indonesian's Scripter now!
Nuginity is offline   Reply With Quote
Old 09/04/2020, 09:30 AM   #4
David (Sabljak)
Huge Clucker
 
Join Date: Nov 2011
Posts: 337
Reputation: 18
Default Re: Prevent Damage

What are you trying to achieve? Prevent damage from who? To playerid? Who is giving him damage and how?
David (Sabljak) is offline   Reply With Quote
Old 09/04/2020, 10:58 AM   #5
Nuginity
Big Clucker
 
Nuginity's Avatar
 
Join Date: Feb 2020
Location: Indonesia (Jakarta)
Posts: 61
Reputation: 2
Default Re: Prevent Damage

Quote:
Originally Posted by David (Sabljak) View Post
What are you trying to achieve? Prevent damage from who? To playerid? Who is giving him damage and how?
actually this is not the real code, but it's implementing everything
__________________
Nusantara Freeroam
Current Stage : ALPHA
-------------------------------------------
We Need an Indonesian's Scripter now!
Nuginity is offline   Reply With Quote
Old 09/04/2020, 11:02 AM   #6
Adamoneoone
Huge Clucker
 
Join Date: Sep 2014
Posts: 450
Reputation: 31
Default Re: Prevent Damage

Use OnPlayerTakeDamage instead perhaps?
Adamoneoone is offline   Reply With Quote
Old 09/04/2020, 11:54 AM   #7
v1k1nG
Huge Clucker
 
v1k1nG's Avatar
 
Join Date: Feb 2018
Posts: 492
Reputation: 35
Default Re: Prevent Damage

Quote:
Originally Posted by Adamoneoone View Post
Use OnPlayerTakeDamage instead perhaps?

He is using weapon-config that as far as I know is more responsive than standard damage system.



https://github.com/oscar-broman/samp...ster/README.md

Returning 0 in OnPlayerDamage will prevent damage from being inflicted.
__________________
Currently working on a PvE server, a gangwar server and a team deathmatch one.

Want to test?

My test server: 51.91.122.18:7778
My Discord contact: [SF]kAn3#9933
v1k1nG is online now   Reply With Quote
Old 09/04/2020, 12:44 PM   #8
Adamoneoone
Huge Clucker
 
Join Date: Sep 2014
Posts: 450
Reputation: 31
Default Re: Prevent Damage

Quote:
Originally Posted by v1k1nG View Post
He is using weapon-config that as far as I know is more responsive than standard damage system.



https://github.com/oscar-broman/samp...ster/README.md

Returning 0 in OnPlayerDamage will prevent damage from being inflicted.
Then shouldn’t the callback be OnPlayerDamage directly? He showed OnPlayerGiveDamage in his first post
Adamoneoone is offline   Reply With Quote
Old 09/04/2020, 01:06 PM   #9
Kasichok
Big Clucker
 
Kasichok's Avatar
 
Join Date: Sep 2018
Location: weed farm
Posts: 97
Reputation: 35
Default Re: Prevent Damage

First use OnPlayerTakeDamage its more accurate OnPlayerGiveDamage is being called only if you gave damage to a player on your screen but not for real (desync) OnPlayerTakeDamage is being called if you actually hit the player

PHP Code:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    new 
Float:hamount;
    if(
issuerid == 0xFFFF) return 1;
    
GetPlayerHealth(playeridhamount);
    if(
GetPVarInt(playerid,"police") == 0)
    {
           
SetPlayerHealth(playeridhamount);
    }
    return 
1;

__________________



STRESSED? TRY KASICHOK AND RELAX


Kasichok is offline   Reply With Quote
Old 09/04/2020, 01:06 PM   #10
v1k1nG
Huge Clucker
 
v1k1nG's Avatar
 
Join Date: Feb 2018
Posts: 492
Reputation: 35
Default Re: Prevent Damage

Quote:
Originally Posted by Adamoneoone View Post
Then shouldn’t the callback be OnPlayerDamage directly? He showed OnPlayerGiveDamage in his first post
Ah my bad. I've misread the post.
__________________
Currently working on a PvE server, a gangwar server and a team deathmatch one.

Want to test?

My test server: 51.91.122.18:7778
My Discord contact: [SF]kAn3#9933
v1k1nG is online now   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
How can i block on foot damage to vehicle? (Fist damage) SmileyGOD Scripting Help 2 17/01/2020 09:20 PM
weapon-config self damage and weaponized vehicle damage Chyakka Scripting Help 6 13/12/2018 04:28 PM
Prevent AFK Player Damage PoniStar Scripting Help 11 13/09/2018 06:26 AM
Does this prevent damage of any type? SeanDenZYR Scripting Help 1 25/05/2018 11:08 AM
[Tutorial] How to prevent damage Manyula Tutorials 8 04/05/2016 04:19 PM


All times are GMT. The time now is 10:31 PM.


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