AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how would i do this (https://forums.alliedmods.net/showthread.php?t=10395)

CrAzy F00L 02-18-2005 06:05

how would i do this
 
im trying to make a plugin were u can go up to sum1 and slap them with a press of a button, i know how to set up everything but the part that actualy can tell if ur touching the other player. im fairly new at the engine module if it involves that

knekter 02-18-2005 10:37

hmmm
 
the easiest way to do this would be to set a task at the begining of the round that loops every 0.1 seconds. Then find the alive players and their origin and use get_distance(p1origin, p2origin). If distance < lets say 5 maybe, you hit them.

CrAzy F00L 02-18-2005 15:18

hrmm, couldn't there be a way for it to just get the origin of the person im aiming at, and find the difference from my origin

XxAvalanchexX 02-18-2005 15:34

get_user_aiming
get_entity_distance

xeroblood 02-18-2005 16:24

I wrote this for amx awhile ago, with minor conversions you should have no problem getting it to work for AMXX 1.0..

Only, I called it Punch, not slap...

Mainly, I used it so when a player (like an afk) is blocking a doorway, I can punch him outta the way..

Edit: with the beautiful backward-compatibility of AMXX this compiled fine without changing anything at all...

Code:
/***************************************************************************  *   rs_punch.sma               Version 1.2                Date: FEB/20/2004  *  *   RS Punch (Punch Players Close To You!)  *  *   By:    Rob Secord  *   Alias: xeroblood (aka; sufferer)              <a href="mailto:[email protected]">[email protected]</a>  *  *   Developed using:  AMX 0.9.8  *   Tested On:        CS 1.6 (STEAM)  *  ***************************************************************************  *   CREDITS:  *      As Always, Much of the credit goes to The People and Tutorials at  *      <a href="http://amxmod.net/forums" target="_blank" rel="nofollow noopener">http://amxmod.net/forums</a> for lots of information, and good advice!!  *  *      --> novex   = Original Idea!!  *      --> knocker = Suggested plugin respond to Chat Keywords  *  ***************************************************************************  *   UPDATED in v1.1  *      - Added Help MOTD on Say /punch_help  *      - Added Say <Keyword> feature for Auto-Punch or Help (thru CVAR)  *      - Added Punchers Name to Victims Message (thru CVAR)  *      - Added CVAR sv_punch_random To Toggle Random Direction on user_slap()  *      - Fixed so DEAD Players Can't Punch!  *  ***************************************************************************  *  Admin CVARs:  *  *    sv_punch_allow    < 1|0 > -- Turns Plugin On or Off  *    sv_punch_restrict < 1|0 > -- 1 = Only Admins Can Punch People, 0 = Everyone can punch  *    sv_punch_team     < 1|0 > -- Players Can Punch Teammates  *    sv_punch_admin    < 1|0 > -- Players Can Punch Admins  *    sv_punch_power     < # >  -- Amount of Damage Done By Punches  *    sv_punch_delay     < # >  -- Delay in Seconds between each Punch (Prevents Punch Spam)  *    sv_punch_limit     < # >  -- Max Player Punches Per Round (0 = Unlimited)  *    sv_punch_reach     < # >  -- The Players Punch Reach (40=default)  *    sv_punch_random   < 1|0 > -- 1 = Random Direction on Punch  *    sv_punch_msg      <"xxx"> -- The Message Shown to the Victim when Punched!  *    sv_punch_by       < 1|0 > -- Displays Punchers Name With The Message Shown to Victim  *    sv_punch_help     < 1|0 > -- Displays help info to players who say /punch_help  *                 0 = Minimal Help + Auto-Punch on say keywords in g_szSayPunch array  *                 1 = Full Help (keywords trigger help info)(default)  *  ***************************************************************************  *  *  Note: Admins are recognized by this plugin using:  *        ADMIN_CHAT  or  ADMIN_LEVEL_A   flags.  *  (the most basic admins on my server have at least Chat/Custom Level A)  *  *  Also, if sv_punch_restrict is 1, then only admins with ADMIN_LEVEL_B  *  flag can punch players.  *  **************************************************************************/ #include <amxmod> #include <amxmisc> #define ADMIN_LEVEL  ((ADMIN_CHAT)|(ADMIN_LEVEL_A)) #define MAX_PLAYERS  32 #define PUNCH_SOUNDS 3 #define PUNCH_LINES  4 new g_nLastPunch[MAX_PLAYERS] new g_nPunchesThrown[MAX_PLAYERS] new g_szSayPunch[PUNCH_LINES][] = { "punch", "slap", "block", "move" } public plugin_init() {     register_plugin( "RS Punch", "1.2", "xeroblood" )     register_clcmd( "punch",    "ClCmd_Punch", _, "- Punches A Player (Helps Move AFKs)" )     register_clcmd( "say",      "ClCmd_HandleSay" )     register_clcmd( "say_team", "ClCmd_HandleSay" )     register_event( "ResetHUD", "Event_NewRound", "b" )     register_cvar( "sv_punch_allow",    "1" )   // 1 = Plugin is ON     register_cvar( "sv_punch_restrict", "0" )   // 1 = Only Admins Can Punch     register_cvar( "sv_punch_team",     "0" )   // 1 = Can Punch Team     register_cvar( "sv_punch_admin",    "0" )   // 1 = Can Punch Admins     register_cvar( "sv_punch_random",   "1" )   // 1 = Random Direction on Punch     register_cvar( "sv_punch_power",    "5" )   // HP dmg/punch     register_cvar( "sv_punch_delay",    "3" )   // Seconds between punches     register_cvar( "sv_punch_limit",    "10" )  // 0 = No Limit     register_cvar( "sv_punch_reach",    "40" )  // Must be > 35     register_cvar( "sv_punch_help",     "1" )   // 1 = Display Help, 0 = Just Punch     register_cvar( "sv_punch_by",       "1" )   // 1 = Display Punchers Name with MSG     register_cvar( "sv_punch_msg",      "You Have Been Punched!" ) } #if !defined NO_STEAM public client_authorized( id ) #else public client_connect( id ) #endif {     g_nLastPunch[id-1] = get_user_time( id )     g_nPunchesThrown[id-1] = 0 } public client_disconnect( id ) {     g_nLastPunch[id-1] = 0     g_nPunchesThrown[id-1] = 0 } public Event_NewRound( id ) {     g_nPunchesThrown[id-1] = 0 } public ClCmd_Punch( id ) {     if( !get_cvar_num("sv_punch_allow") )         return PLUGIN_HANDLED     if( get_cvar_num("sv_punch_restrict") && !(get_user_flags(id) & ADMIN_LEVEL_B) )         return PLUGIN_HANDLED     if( !is_user_alive( id ) )     {         client_print( id, print_chat, "Dead People Throw No Punches!" )         return PLUGIN_HANDLED     }     if( get_cvar_num("sv_punch_limit") > 0 )     {         if( g_nPunchesThrown[id-1] >= get_cvar_num("sv_punch_limit") )         {             client_print( id, print_chat, "You Punch Too Much! Use a GUN!" )             return PLUGIN_HANDLED         }     }     if( (get_user_time(id)-g_nLastPunch[id-1]) < get_cvar_num("sv_punch_delay") )         return PLUGIN_HANDLED     new vID, vBody     get_user_aiming( id, vID, vBody )     if( vID < 1 || !vBody ) return PLUGIN_HANDLED     new origins[2][3]     get_user_origin( id, origins[0] )     get_user_origin( vID, origins[1] )     if( get_distance( origins[0], origins[1] ) > get_cvar_num("sv_punch_reach") )         return PLUGIN_HANDLED     if( access( vID, ADMIN_LEVEL) && !get_cvar_num("sv_punch_admin") )     {         client_print( id, print_chat, "That ADMIN Is Too Strong For Your Pesky Punches!!" )         return PLUGIN_HANDLED           }     if( (get_user_team(id) == get_user_team(vID)) && !get_cvar_num("sv_punch_team") )     {         client_print( id, print_chat, "You Cannot Punch Your Teammates!!" )         return PLUGIN_HANDLED           }     g_nPunchesThrown[id-1]++     g_nLastPunch[id-1] = get_user_time( id )     new nDir = (get_cvar_num("sv_punch_random")==1)?1:0     user_slap( vID, get_cvar_num("sv_punch_power"), nDir )     new szMsg[128]     get_cvar_string( "sv_punch_msg", szMsg, 127 )     if( get_cvar_num("sv_punch_by") == 1 )     {         new szName[32]         get_user_name( id, szName, 31 )         format( szMsg, 127, "%s: %s", szName, szMsg )     }     client_print( vID, print_chat, szMsg )     return PLUGIN_HANDLED } public ClCmd_HandleSay( id ) {     if( !get_cvar_num("sv_punch_allow") )         return PLUGIN_CONTINUE     new i, Speech[192], Temp[32]     read_args(Speech,192)     remove_quotes(Speech)     if( equali(Speech, "/punch_help") || equali(Speech, "punch_help") )     {         ClCmd_HelpMe( id )         return PLUGIN_CONTINUE     }     for( i = 0; i < PUNCH_LINES; i++ )     {         format( Temp, 31, "/%s", g_szSayPunch[i] )         if( (containi(Speech, Temp) != -1) || (containi(Speech, g_szSayPunch[i]) != -1) )         {             if( get_cvar_num("sv_punch_help") == 1 )                 ClCmd_PunchHelp( id )             else                 ClCmd_Punch( id )             break         }     }     return PLUGIN_CONTINUE } public ClCmd_PunchHelp( id ) {     set_hudmessage( 10, 255, 10, _, _, _, 1.0, 5.0, _, _, 2 )     show_hudmessage( id, "Say /punch_help for help Punching Players!" )     return PLUGIN_HANDLED } public ClCmd_HelpMe( id ) {     new nLen, szHelpMsg[768] #if !defined NO_STEAM     nLen = format( szHelpMsg, 767, "<html><head><title></title></head><body bgcolor=#3E4637 text=#C4B550>" )     nLen += format( szHelpMsg[nLen], 767-nLen, " <center><b><font color=red>RS Punch -- My Fist Will Move Ya!</font></b></center>" )     nLen += format( szHelpMsg[nLen], 767-nLen, " Helps move people out of your way! " )     nLen += format( szHelpMsg[nLen], 767-nLen, "To Punch Players, bind a key to punch like so: bind x punch " )     nLen += format( szHelpMsg[nLen], 767-nLen, "<b><u>RS Punch Settings</u></b>: " )     nLen += format( szHelpMsg[nLen], 767-nLen, "Punch Power:   <b>%d</b> HP ", get_cvar_num("sv_punch_power") )     nLen += format( szHelpMsg[nLen], 767-nLen, "Limit / Round: <b>%d</b> Punches ", get_cvar_num("sv_punch_limit") )     nLen += format( szHelpMsg[nLen], 767-nLen, "Punch Delay:   <b>%d</b> Seconds ", get_cvar_num("sv_punch_delay") )     nLen += format( szHelpMsg[nLen], 767-nLen, "Can Punch Admins? <b>%s</b> ", (get_cvar_num("sv_punch_admin")==1)?"Yes":"No" )     nLen += format( szHelpMsg[nLen], 767-nLen, "Can Punch Team?   <b>%s</b> ", (get_cvar_num("sv_punch_team")==1)?"Yes":"No" )     nLen += format( szHelpMsg[nLen], 767-nLen, " <center><b><font color=red>Knock Yourself Out!!</font></b></center></p></body></html>" ) #else     nLen = format( szHelpMsg, 767, "Allows you to Punch another player!^n" )     nLen += format( szHelpMsg[nLen], 767-nLen, "Helps move people out of your way!^n^n" )     nLen += format( szHelpMsg[nLen], 767-nLen, "To Punch Players, bind a key to punch like so: bind x punch^n^n" )     nLen += format( szHelpMsg[nLen], 767-nLen, "RS Punch Settings:^n" )     nLen += format( szHelpMsg[nLen], 767-nLen, "Punch Power --> %d HP^n", get_cvar_num("sv_punch_power") )     nLen += format( szHelpMsg[nLen], 767-nLen, "Limit/Round --> %d Punches^n", get_cvar_num("sv_punch_limit") )     nLen += format( szHelpMsg[nLen], 767-nLen, "Punch Delay --> %d Seconds^n", get_cvar_num("sv_punch_delay") )     nLen += format( szHelpMsg[nLen], 767-nLen, "Can Punch Admins? %s^n", (get_cvar_num("sv_punch_admin")==1)?"Yes":"No" )     nLen += format( szHelpMsg[nLen], 767-nLen, "Can Punch Team?   %s^n^n", (get_cvar_num("sv_punch_team")==1)?"Yes":"No" )     nLen += format( szHelpMsg[nLen], 767-nLen, "Knock Yourself Out!!" ) #endif     show_motd( id, szHelpMsg, "RS Punch - Help" )     return PLUGIN_HANDLED }

CrAzy F00L 02-18-2005 16:57

ya i remember when u made this, i was way to lazy to search for it :-p

well im actualy making a superhero "rick james" that does this as well as play the "im rick james bitch sound" ill make sure to giive u credit,

thanks


All times are GMT -4. The time now is 14:09.

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