AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   VS Limbshot (https://forums.alliedmods.net/showthread.php?t=54064)

Afion 04-16-2007 09:43

VS Limbshot
 
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 :D

regalis 04-16-2007 11:15

Re: VS Limbshot
 
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

Afion 04-16-2007 12:58

Re: VS Limbshot
 
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 :?

regalis 04-16-2007 15:39

Re: VS Limbshot
 
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..

Afion 04-16-2007 18:04

Re: VS Limbshot
 
Thanks for looking at it anyway :wink:

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...

XxAvalanchexX 04-16-2007 18:43

Re: VS Limbshot
 
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).

Afion 04-16-2007 20:02

Re: VS Limbshot
 
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...

regalis 04-16-2007 21:09

Re: VS Limbshot
 
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 ;)

Afion 04-17-2007 09:07

Re: VS Limbshot
 
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 :mrgreen:

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 :up:. I learned a lot while making this plugin.


All times are GMT -4. The time now is 06:46.

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