Raised This Month: $ Target: $400
 0% 

VS Limbshot


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Afion
Junior Member
Join Date: Apr 2007
Location: Belgium
Old 04-16-2007 , 09:43   VS Limbshot
Reply With Quote #1

I made a plugin for the Vampire Slayer mod but it has a nasty bug in it. The idea is that vampires should always kill the slayer and not slap them to 5 hp if you hit them on a limb. This is my code:
Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#define PLUGIN "VS No-Limbshot"
#define VERSION "2.0beta2"
#define AUTHOR "Afion"
////////////////////////////////////////////////////////////////////////////////////////////////////
public plugin_init() 
{
 register_plugin(PLUGIN, VERSION, AUTHOR)
 register_event("Damage", "Event_Damage", "b")
}
////////////////////////////////////////////////////////////////////////////////////////////////////
public Event_Damage(id) 
{
 new attacker = get_user_attacker(id)
 new victim = id
 new attackername[21]
 new victimname[21]
 
 get_user_name(attacker,attackername,20)
 get_user_name(victim,victimname,20)
 
 if(attacker == 0 || victim==0)
  return PLUGIN_CONTINUE
 
 if ((get_team(victim) == 2) && (get_team(attacker) == 1) && is_user_alive(victim)) 
  {
  user_silentkill(victim) 
 
  set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
  DeathMessage(attacker,victim,"claw")
 
  set_user_frags(attacker, get_user_frags(attacker)+1)
 
  console_print(0, "%s limbed %s", attackername, victimname)
  }
 return PLUGIN_CONTINUE
}
////////////////////////////////////////////////////////////////////////////////////////////////////
stock get_team(id)
{
 new Team[8]
 get_user_team(id,Team,7)
 if(equali(Team,"VAMPIRE"))
  return 1
 if(equali(Team,"SLAYER"))
  return 2
 return 0
}
////////////////////////////////////////////////////////////////////////////////////////////////////
stock DeathMessage(attacker, victim, const weapon[])
{
    message_begin(MSG_ALL, get_user_msgid("DeathMsg"), {0,0,0}, 0) 
    write_byte(attacker)
    write_byte(victim)
    write_string(weapon)
    message_end()
}
It seems to work just fine. The slayer dies, the correct deathmessage pops up, but vamp stats dont change and the slayer gets -1 frag and +1 death. The really strange thing is that the next time the slayer dies (doesnt matter how), the vamp does get the +1 frag and the -1 frag for the slayer disappears. Im a noob at scripting and dont know how to fix it. The code probably has some other things that could be improved too.
Any reply that will improve the plugin or help me understand small and amxx better will be very appreciated
Afion is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-16-2007 , 11:15   Re: VS Limbshot
Reply With Quote #2

I'm new at this too...but maybe switch the calls of your funtions..

Code:
  user_silentkill(victim) 

  set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
  DeathMessage(attacker,victim,"claw")
 
  set_user_frags(attacker, get_user_frags(attacker)+1)
change to

Code:
  set_user_frags(attacker, get_user_frags(attacker)+1)

  user_silentkill(victim) 
  set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
  DeathMessage(attacker,victim,"claw")
But as already said, i'm not sure ;)
hope that helps...

greetz regalis
__________________
regalis is offline
Afion
Junior Member
Join Date: Apr 2007
Location: Belgium
Old 04-16-2007 , 12:58   Re: VS Limbshot
Reply With Quote #3

Nope, that doesnt help.
I tried changing the PLUGIN_CONTINUE to PLUGIN_HANDLED also, but without result

I tried to compile it with the web compiler on the amxx site and i got this error: /home/groups/amxmodx/tmp3/textC6HWob.sma(71) : error 035: argument type mismatch (argument 1)

I dont get any warnings or errors on the compiler that was with the amxx installation
Afion is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-16-2007 , 15:39   Re: VS Limbshot
Reply With Quote #4

i tried it too in webcompiler and local...local without error and in webcompiler with the same error...
In the documentation is the same "stock DeathMessage" like yours...strange!

Sorry i can't find the bug..
__________________
regalis is offline
Afion
Junior Member
Join Date: Apr 2007
Location: Belgium
Old 04-16-2007 , 18:04   Re: VS Limbshot
Reply With Quote #5

Thanks for looking at it anyway

Anyone else got some ideas? I dont know if the webcompiler error has something to do with it cuz the one compiled on the local compiler works just fine, only stats are messed up as long as the slayer doesnt get killed a second time...
Afion is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 04-16-2007 , 18:43   Re: VS Limbshot
Reply With Quote #6

Using set_user_frags only changes the player's frags internally. This means that the actual value is changed, but what is displayed on the scoreboard is not. You will need to figure out how VS's ScoreInfo message works, and send out one of those with the new information for it to appear right away.

I've also noticed some odd behaviour with user_silentkill that was giving players the appearance of -1 frags on the scoreboard until the game refreshed it (ie: the player kills someone or dies).
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Afion
Junior Member
Join Date: Apr 2007
Location: Belgium
Old 04-16-2007 , 20:02   Re: VS Limbshot
Reply With Quote #7

i changed the code to this:
PHP Code:
 if ((get_team(victim) == 2) && (get_team(attacker) == 1) && is_user_alive(victim)) //Vamp attacks slayer and slayer still lives
  

  
set_user_frags(attackerget_user_frags(attacker)+1)
 
  
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_ONCE)
  
user_kill(victim)
  
set_user_frags(victimget_user_frags(victim)+1)
 
  
make_deathMsg(attacker,victim,"claw")
 
  
console_print(0"%s limbed %s"attackernamevictimname)
  }
 return 
PLUGIN_HANDLED 
It does the same, but solves the silentkill problem and only leaves the set_user_frags problem.

Are you saying that i have to hook the ScoreInfo message and create my own, like i did with the DeathMsg? Or is there a way to only refresh the frags? Im trying to figure out the ScoreInfo with the register_message command but i have no idea if that is the right way or if that even works...
Afion is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-16-2007 , 21:09   Re: VS Limbshot
Reply With Quote #8

I don't know if you need this but with that plugin you can log all (i think all) messages into a log-file...
Maybe it is usefull for you!?

http://forums.alliedmods.net/showthread.php?p=65983

greetz and thx regalis ;)
__________________
regalis is offline
Afion
Junior Member
Join Date: Apr 2007
Location: Belgium
Old 04-17-2007 , 09:07   Re: VS Limbshot
Reply With Quote #9

PHP Code:
/*This is a plugin to get rid of the annoying limbshot in Vampire Slayer. Needs fun and engine module.
Made by Afion*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#define PLUGIN "VS No-Limbshot"
#define VERSION "2.0RC1"
#define AUTHOR "Afion"
new Ressurections[32]
new 
KOs[32]
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public plugin_init()
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
register_event("Damage""Event_Damage""b""2>0")
 
register_message83"ScoreInfo" )
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public Event_Damage(id)
{
 new 
attacker get_user_attacker(id)
 new 
victim id
 
 
if(attacker == || victim==0)
  return 
PLUGIN_HANDLED
 
 
if ((get_team(victim) == 2) && (get_team(attacker) == 1) && is_user_alive(victim)) //Vamp attacks slayer and slayer still lives
 

  
set_user_frags(attackerget_user_frags(attacker)+1)
  
make_ScoreInfo(attackerget_user_frags(attacker), get_user_deaths(attacker), Ressurections[attacker-1], KOs[attacker-1], 1)
  
//added one vamp frag and updated the scoreboard
 
  
set_user_frags(victimget_user_frags(victim)+1)
  
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_ONCE)
  
user_kill(victim)
  
//added one slayer frag and kills slayer. cannot use silentkill cuz the scoreboard shows -1 frag untill next kill or death
 
  
make_deathMsg(attacker,victim,"claw")
  
//client_print (0, print_center, "LIMBSHOT!!!") //just for testing purpose
 
}
 return 
PLUGIN_HANDLED
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
stock get_team(id//0=Spectator, 1=Vampire, 2=Slayer
{
 new 
Team[8]
 
get_user_team(id,Team,7)
 if(
equali(Team,"VAMPIRE"))
  return 
1
 
if(equali(Team,"SLAYER"))
  return 
2
 
return 0
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
stock make_deathMsg(killervictimweapon[])
{
 
message_begin(MSG_ALLget_user_msgid("DeathMsg"), {0,0,0}, 0
 
write_byte(killer)
 
write_byte(victim)
 
write_string(weapon)
 
message_end()
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public ScoreInfo()
{
 
set_msg_arg_int2ARG_SHORTget_user_frags(get_msg_arg_int(1)))//updates the scoreboard to not show -1 frag for slayer
           //does not help with silentkill
 
Ressurections[get_msg_arg_int(1)-1]=get_msg_arg_int(4)
 
KOs[get_msg_arg_int(1)-1]=get_msg_arg_int(5)
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
stock make_ScoreInfo(idfragsdeathsressurectionskosteam)
{
 
message_begin(MSG_ALLget_user_msgid("ScoreInfo"), {0,0,0}, 0
 
write_byte(id)
 
write_short(frags)
 
write_short(deaths)
 
write_short(ressurections)
 
write_short(kos)
 
write_short(team)
 
message_end()

This version works great. I havent found a single flaw so far and the scoreboard gets updated correctly

If you should find anything that can be improved, no matter how small it is, plz say so.

And should i post this in the plugins section? I dont get that approving thing, what does it need to be approved for? I only want that people who want to use it can find it easily...

Anyway, thanks to avalanche and regalis for the usefull tips . I learned a lot while making this plugin.

Last edited by Afion; 04-17-2007 at 10:55. Reason: found a little error
Afion is offline
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 06:46.


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