Raised This Month: $ Target: $400
 0% 

client_PreThink Crashing Server...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-25-2005 , 17:03   client_PreThink Crashing Server...
Reply With Quote #1

Hey all

I'm just trying to make someone invulnerable for a single shot (telling them they dodged it)... here's my code, not sure how it works. (I tried calling godmode from damageevent, but problem is they already do damage, then damageevent is not called again cuz they are god)

Code:
public client_PreThink(id) {     if(entity_get_int(id, EV_INT_button) & ~IN_ATTACK)    {         new Enemy = id, Victim         new Float:Distance = get_user_aiming(id, Victim)         new EnemyName[34], VictimName[34]                 get_user_name(Enemy, EnemyName, 33)         get_user_name(Victim, VictimName, 33)                 //evade         new DodgeChance = random_num(0, 100)         new DodgeMod = (PlayerSkill[Victim][SKILL_DODGE] - PlayerSkill[Enemy][SKILL_TRUESHOT])                         if(DodgeMod >= DodgeChance)         {             client_print(Victim, print_chat, "You dodged a shot by %s!", EnemyName)             client_print(0, print_console, "DodgeMod(%i)/DodgeChance(%i) = SUCCESS!", DodgeMod, DodgeChance)             client_print(Enemy, print_chat, "%s dodged your shot!", VictimName)                         set_user_godmode (Victim, 1)             return PLUGIN_HANDLED         }         else         {             client_print(0, print_console, "Skill(%i)/DodgeChance(%i) = FAILURE!", PlayerSkill[Victim][SKILL_DODGE], DodgeChance)             set_user_godmode(Victim)                        return PLUGIN_HANDLED         }     } }

Any idea whats wrong/how i can fix it/ a better way to do this?
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-25-2005 , 17:13  
Reply With Quote #2

Use the damage event, check how much damage they did, and then add that health back to the victim!! It is easier, but it will not work for HS and stuff that does more than 100 damage.. an easy work-around is to set the users HP to something like 356, then the HUD will only show 100 HP but the user will have 356, so HS are taken care of.. then, when a users HP is below 256 just kill them!!
xeroblood is offline
Send a message via MSN to xeroblood
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-25-2005 , 17:19  
Reply With Quote #3

I tried that xero.. cuz that's what wc3 code did, and it did not work properly (hs = kill) on top of that you are still gushing blood everywhere, and your armour gets hurt
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 04-25-2005 , 17:20  
Reply With Quote #4

I helped him out a bit on MSN..
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-25-2005 , 17:21  
Reply With Quote #5

OK.. getting spammed with this error:

Quote:
L 04/25/2005 - 1733: [AMXX] Run time error 4 (index out of bounds) on line 20 (file "ma_damageevents.inc").
added stuff for player0 to stop this eror:
Quote:

L 04/25/2005 - 173:16: [FUN] Player out of range (17)
L 04/25/2005 - 173:16: [AMXX] Native error in "set_user_godmode" on line
but i think it's checking everytime i move.. because it's checking when noone is shooting.... new code below:

Code:
public client_PreThink(id) {     if(entity_get_int(id, EV_INT_button) & ~IN_ATTACK)    {         new Victim = read_data(2)         new Enemy = id, BodyPart         new Float: distance = get_user_aiming(id, Enemy, BodyPart)         new EnemyName[34], VictimName[34]                 get_user_name(Enemy, EnemyName, 33)         get_user_name(Victim, VictimName, 33)                 if (Victim == 0 || Enemy == 0)         {             return PLUGIN_HANDLED         }                 //evade         new DodgeChance = random_num(0, 100)         new DodgeMod = (PlayerSkill[Victim][SKILL_DODGE] - PlayerSkill[Enemy][SKILL_TRUESHOT])                         if(DodgeMod >= DodgeChance)         {             client_print(Victim, print_chat, "You dodged a shot by %s!", EnemyName)             client_print(0, print_console, "DodgeMod(%i)/DodgeChance(%i) = SUCCESS!", DodgeMod, DodgeChance)             client_print(Enemy, print_chat, "%s dodged your shot!", VictimName)                         set_user_godmode (Victim, 1)             return PLUGIN_HANDLED         }         else         {             client_print(0, print_console, "Skill(%i)/DodgeChance(%i) = FAILURE!", PlayerSkill[Victim][SKILL_DODGE], DodgeChance)             set_user_godmode(Victim)                        return PLUGIN_HANDLED         }     }     return PLUGIN_HANDLED }
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-25-2005 , 18:27   Update....
Reply With Quote #6

Changed code to this:

Code:
public client_PreThink(id) {     new button = get_user_button(id)     if(button & IN_ATTACK)     {         new Victim = read_data(2)         new Enemy = id, BodyPart         new Float: distance = get_user_aiming(id, Victim, BodyPart)         new EnemyName[34], VictimName[34]                 get_user_name(Enemy, EnemyName, 33)         get_user_name(Victim, VictimName, 33)                 if (Victim == 0 || Enemy == 0 || is_user_alive(Enemy)==0 || is_user_alive(Victim)==0)         {             return PLUGIN_HANDLED         }                 //evade         new DodgeChance = random_num(0, 100)         new DodgeMod = (PlayerSkill[Victim][SKILL_DODGE] - PlayerSkill[Enemy][SKILL_TRUESHOT])                         if(DodgeMod >= DodgeChance)         {             client_print(Victim, print_chat, "You dodged a shot by %s!", EnemyName)             client_print(0, print_console, "DodgeMod(%i)/DodgeChance(%i) = SUCCESS!", DodgeMod, DodgeChance)             client_print(Enemy, print_chat, "%s dodged your shot!", VictimName)                         if(is_user_alive(Victim))             {                 set_user_godmode (Victim, 1)                 return PLUGIN_HANDLED             }         }         else         {             if(is_user_alive(Victim))             {                 client_print(0, print_console, "Skill(%i)/DodgeChance(%i) = FAILURE!", PlayerSkill[Victim][SKILL_DODGE], DodgeChance)                 set_user_godmode(Victim)                            return PLUGIN_HANDLED             }         }     }     return PLUGIN_HANDLED }

and it works fine, except for the fact that it runs around 6 - 8 times per shot (tested with usp) is there any way to stop this? I only want it ran once per shot.

EDIT:

Found this off a post and added it to help, but didn't work
Code:
public curweapon(id) {    new wpnid = read_data(2)    new clip = read_data(3)    if (lastweap[id] != wpnid){       //Changed weapons    }    else if ( lastclip[id] > clip ) {       if (wpnid != CSW_C4 && wpnid != CSW_HEGRENADE && wpnid != CSW_FLASHBANG && wpnid != CSW_SMOKEGRENADE && wpnid != CSW_KNIFE) {         //Fired a Bullet         UserFired[id] = 1       }       else         UserFired[id] = 0    }    lastclip[id] = clip    lastweap[id] = wpnid }
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-25-2005 , 23:01  
Reply With Quote #7

Quote:
Originally Posted by BioHazardousWaste
I tried that xero.. cuz that's what wc3 code did, and it did not work properly (hs = kill) on top of that you are still gushing blood everywhere, and your armour gets hurt
Well, 356 was an example (a poor one) but it demonstrated the basics of the idea rather well.. you see, if you give a player 255 HP it will show up as 255 on the HUD, but that is the max value of the HUD display, so if you give the player 256 HP it will show up as 1 HP on the HUD (it just recycles through).. Using this idea you could set the users HP to 1356 (or something) that way a HS with an AWP + WC3 Powers won't kill the player unless your code determines that they should die; then kill them!
The only down-side is that you have to manage HP yourself, and spectators/dead people will see the users true HP as 1000+ even though they will die after 100 HP damage.. (Some people see this in-game and don't understand that, so they think people really have 1000+ hP )
Seems simpler then what you are attempting with PreThink, and also would be less laggy, since PreThink is always called (and usually more than once before any action is done), whereas HP management is only done when needed, as in the Damage/Death events, and any other special effects you add..

Just my 0.5 cents!
xeroblood is offline
Send a message via MSN to xeroblood
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-25-2005 , 23:46  
Reply With Quote #8

ok.. i guess I could do that, but it just seems stupid to have blood gushing out of somones head and be like you dodged the bullet! also, how would you handle the loss in armour?

EDIT:
Sweet I gained another rank! on my second week here
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
KyleD
Member
Join Date: Mar 2005
Location: Anchorage, AK
Old 04-26-2005 , 02:10  
Reply With Quote #9

Cause you post same damn much! But, you must work on a lot of plugins to have so many questions.
__________________
KyleD is offline
Send a message via MSN to KyleD
BioHazardousWaste
Senior Member
Join Date: Apr 2005
Location: Ontario, Canada =)
Old 04-26-2005 , 21:20  
Reply With Quote #10

lol, most of my days have been spent working on my new matrix mod... technically one plugins, with (currently) about 6 .inc files ... about 1000 lines in total so far. I'd love to help more, but I can't really without knowing how stuff works myself
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.

-Friedrich Nietzsche
BioHazardousWaste is offline
Send a message via MSN to BioHazardousWaste
Reply



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

Forum Jump


All times are GMT -4. The time now is 16:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode