Raised This Month: $ Target: $400
 0% 

get attackers gun


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 02-28-2006 , 01:33   get attackers gun
Reply With Quote #1

hi

im working on a script for surf_ninja.
where if your gun is != to Shotgun and you attack someone whos gun is != shotgun then you get slayed.

how do i use a get_user_weapon or get_weaponname functions?

Code:
public killer_event(id) {         if(!get_cvar_num("surf_enable"))         {                 return PLUGIN_CONTINUE         }         new attacker = get_user_attacker(id)         if(!attacker)         {                 return PLUGIN_CONTINUE         }         new attackerName[18]         new victimName[18]         get_user_name(attacker, attackerName, 17)         get_user_name(id, victimName, 17)             user_kill(attacker,0)         client_print(attacker,print_chat,"You Were Slayed For Attempting To Kill")         set_hudmessage(0, 100, 200, 0.75, 0.50, 2, 0.1, 4.0, 0.02, 0.02, 9)         show_hudmessage(0, "%s", attackerName, " was slayed for attacking %s", victimName)         return PLUGIN_CONTINUE }

heres the orginal un-modifed code this is a working script atm, just trying to add some more fuctionality to it.

so i want to it to slay anyone who doesnt have a shotgun and attacks. but not slay them if they attack the shotgun carrier and vice versa
__________________
Dont know how to add admins?

use my program
http://www.amxmodx.org/forums/viewto...=129092#129092

it does the work for you ... sort of
Anthraxnz is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-28-2006 , 01:46  
Reply With Quote #2

Make a new variable and add a third parameter to get_user_attacker. That will give you the weapon ID of the attacker.
__________________
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
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 02-28-2006 , 01:56  
Reply With Quote #3

already got that its stored in a varable called "attacker"

found this in someones Question
Code:
    new ammo, clip, weapon = get_user_weapon(id,clip,ammo)     new weapName[33]     get_weaponname(weapon,weapName,32)

how do i check if weapon is a scout or knife?
__________________
Dont know how to add admins?

use my program
http://www.amxmodx.org/forums/viewto...=129092#129092

it does the work for you ... sort of
Anthraxnz is offline
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 02-28-2006 , 01:59  
Reply With Quote #4

o right now i see wot u mean.
but how do i still check to see if its a scout
__________________
Dont know how to add admins?

use my program
http://www.amxmodx.org/forums/viewto...=129092#129092

it does the work for you ... sort of
Anthraxnz is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-28-2006 , 02:00  
Reply With Quote #5

Assuming weapon contains the weapon ID..
Code:
if(weapon == CSW_SCOUT) {   // }
__________________
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
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 02-28-2006 , 03:25  
Reply With Quote #6

Code:
/* Surf Slayer    Written by Anthrax    Cvars: surf_enable 1 | 0    1 = On    0 = Off    Description:    This is designed for surf servers, when a player attacks another player    the attacking player will be kill instantly, leaving the other player to    continue on with trying to surf.         Version History:     3.00    - Modifed by anthrax to allow killing with the prize weapon         1.00b   - Modified (Anders Dog) to send HUD messages to everyone         1.00    - Created by Anthrax */ #include <amxmodx> #include <engine> #include <amxmisc> public plugin_init() {         register_plugin("Surf Patrol","3.0","Anthrax")         register_cvar("surf_slayer_enable","1")         register_event("Damage","killer_event","b","2!0","3=0","4!0") } public killer_event(id) {         if(!get_cvar_num("surf_slayer_enable"))         {                 return PLUGIN_CONTINUE         }     new attacker = get_user_attacker(id)     new ammo, clip, weapon = get_user_weapon(attacker,clip,ammo)         if(!attacker)         {                 return PLUGIN_CONTINUE         }         new attackerName[18]         new victimName[18]         get_user_name(attacker, attackerName, 17)         get_user_name(id, victimName, 17)         if( weapon == CSW_SCOUT || CSW_KNIFE ){         user_kill(attacker,0)                 client_print(attacker,print_chat,"You Were Slayed For Attempting To Kill")             set_hudmessage(0, 100, 200, 0.75, 0.50, 2, 0.1, 4.0, 0.02, 0.02, 9)             show_hudmessage(0, "%s", attackerName, " was slayed for attacking %s", victimName)         return PLUGIN_CONTINUE     }     client_print(0,print_chat,"%s",weapon)         return PLUGIN_CONTINUE }

any idea as to why it doesnt work?

if you shoot someone with a usp it kills u.
it just kills you for shooting with any weapon
__________________
Dont know how to add admins?

use my program
http://www.amxmodx.org/forums/viewto...=129092#129092

it does the work for you ... sort of
Anthraxnz is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-28-2006 , 04:00  
Reply With Quote #7

Try this:
Code:
#include <amxmodx> #include <engine> #include <amxmisc> public plugin_init() {     register_plugin("Surf Patrol","3.0","Anthrax")     register_cvar("surf_slayer_enable","1")     register_event("Damage","killer_event","b","2!0") } public killer_event(id) {     if(!get_cvar_num("surf_slayer_enable"))     {         return PLUGIN_CONTINUE     }     new weapon, attacker = get_user_attacker(id, weapon)     if(!is_user_connected(attacker) || !is_user_alive(attacker))     {                 return PLUGIN_CONTINUE     }     new attackerName[33]     new victimName[33]     get_user_name(attacker, attackerName, 32)     get_user_name(id, victimName, 32)         if( weapon == CSW_SCOUT || weapon == CSW_KNIFE )     {         user_kill(attacker,0)                 client_print(attacker,print_chat,"You Were Slayed For Attempting To Kill")             set_hudmessage(0, 100, 200, 0.75, 0.50, 2, 0.1, 4.0, 0.02, 0.02, 9)         new str[201]         format(str , 200 , "%s was slayed for attacking %s", attackerName, victimName);             show_hudmessage(0, str)         return PLUGIN_CONTINUE     }     client_print(0,print_chat,"%s",weapon)     return PLUGIN_CONTINUE }
__________________
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
VEN
Veteran Member
Join Date: Jan 2005
Old 02-28-2006 , 04:35  
Reply With Quote #8

Quote:
if you shoot someone with a usp it kills u.
it just kills you for shooting with any weapon
In case you wondering. This happens because your IF statement is always TRUE. You check if weapon equal to CSW_SCOUT OR if CSW_KNIFE. CSW_KNIFE is always true because it's constant positive integer.
Code:
    if( weapon == CSW_SCOUT || CSW_KNIFE ){         user_kill(attacker,0)
VEN is offline
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 03-01-2006 , 02:53  
Reply With Quote #9

is there a way to store the person who was attacked?


ie store the victims ID in a varable

trying to figure out how to make it so if the attacker has a shotgun then the victim can shoot without being slayed.
heres the code i thoight might work but doesnt

Code:
    //If Victim Has Scout and Attacker has NOT Scout || Knife DO NOT Slay     if( weaponVic == CSW_SCOUT || weaponVic == CSW_KNIFE && weaponAttacker != CSW_SCOUT || weaponAttacker != CSW_KNIFE){         return PLUGIN_CONTINUE     }

This is where it finds out what weapons are in use.
Code:
        new attacker = get_user_attacker(id)     new ammo, clip, weaponAttacker = get_user_weapon(attacker,clip,ammo)         get_user_name(attacker, attackerName, 17)     new victimAttacked = get_user_name(id, victimName, 17)     new ammoVic, clipVic, weaponVic = get_user_weapon(victimAttacked,clipVic,ammoVic)
__________________
Dont know how to add admins?

use my program
http://www.amxmodx.org/forums/viewto...=129092#129092

it does the work for you ... sort of
Anthraxnz 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 20:25.


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