AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get attackers gun (https://forums.alliedmods.net/showthread.php?t=24654)

Anthraxnz 02-28-2006 01:33

get attackers gun
 
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

v3x 02-28-2006 01:46

Make a new variable and add a third parameter to get_user_attacker. That will give you the weapon ID of the attacker.

Anthraxnz 02-28-2006 01:56

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?

Anthraxnz 02-28-2006 01:59

o right now i see wot u mean.
but how do i still check to see if its a scout

v3x 02-28-2006 02:00

Assuming weapon contains the weapon ID..
Code:
if(weapon == CSW_SCOUT) {   // }

Anthraxnz 02-28-2006 03:25

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

v3x 02-28-2006 04:00

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 }

VEN 02-28-2006 04:35

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)

Anthraxnz 03-01-2006 02:53

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)


All times are GMT -4. The time now is 20:25.

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