Raised This Month: $ Target: $400
 0% 

Targeting a player and give noclip


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iplayz
Junior Member
Join Date: Oct 2011
Old 10-06-2011 , 05:41   Targeting a player and give noclip
Reply With Quote #1

Could anyone explain this to me, or give me a tutorial.

I'm very intrested in how this would work^^
iplayz is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-06-2011 , 05:57   Re: Targeting a player and give noclip
Reply With Quote #2

In your function, use get_user_aiming() to retrieve what the client is aiming at. Then use set_user_noclip() to set noclip.

Example:
Code:
public func( id ) {     new target, body;     get_user_aiming( id, target, body );     // check if target is a player     if( target && 1 <= target <= 32 && is_user_alive( target ) )     {         // target is a player and alive         // set noclip on target here         set_user_noclip( target, 1 );     } }
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
iplayz
Junior Member
Join Date: Oct 2011
Old 10-06-2011 , 06:06   Re: Targeting a player and give noclip
Reply With Quote #3

I thought it would be way harder, ur amazing;)
Do you know this aswell:

I want a menu with all names who are alive and when I click for example on 1 player number 1 will receive noclip
iplayz is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-06-2011 , 06:20   Re: Targeting a player and give noclip
Reply With Quote #4

Code:
public func( id ) {     new Players[ 32 ], Client, Num, _Num[ 2 ], Name[ 32 ];     // retrieve all alive players     get_players( Players, Num, "a" );         // create menu     new Menu = menu_create( "Give Noclip to player:", "MenuHandler" );     for( new Index = 0; Index < Num; Index++ )     {         Client = Players[ Index ];                 // get user name         get_user_name( Client, Name, charsmax( Name ) );                 // convert player index to string         num_to_str( Client, _Num, charsmax( _Num ) );                 // add them to menu         menu_additem( Menu, Name, _Num );     }         // display menu     menu_display( id, Menu, 0 ); } public MenuHandler( id, Menu, Item ) {     if( Item == MENU_EXIT )     {         menu_destroy( Menu );                 return;     }         new Info[ 2 ];     new _Access, Callback;     // get key pressed     menu_item_getinfo( Menu, Item, _Access, Info, charsmax( Info ), _, _, Callback );     menu_destroy( Menu );         // set noclip to target index     set_user_noclip( str_to_num( Info ), 1 ); }

EDIT: Added alive check.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Xellath; 10-06-2011 at 06:23.
Xellath is offline
iplayz
Junior Member
Join Date: Oct 2011
Old 10-06-2011 , 06:58   Re: Targeting a player and give noclip
Reply With Quote #5

Quote:
Originally Posted by Xellath View Post
In your function, use get_user_aiming() to retrieve what the client is aiming at. Then use set_user_noclip() to set noclip.

Example:
Code:
public func( id ) {     new target, body;     get_user_aiming( id, target, body );     // check if target is a player     if( target && 1 <= target <= 32 && is_user_alive( target ) )     {         // target is a player and alive         // set noclip on target here         set_user_noclip( target, 1 );     } }
The : set_user_noclip( target, 1);

is giving me a compile error please help?
iplayz is offline
iplayz
Junior Member
Join Date: Oct 2011
Old 10-06-2011 , 07:02   Re: Targeting a player and give noclip
Reply With Quote #6

same with the player list

:

set_user_noclip( str_to_num( Info ), 1 );
iplayz is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 10-06-2011 , 07:19   Re: Targeting a player and give noclip
Reply With Quote #7

Include fun.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
iplayz
Junior Member
Join Date: Oct 2011
Old 10-06-2011 , 07:31   Re: Targeting a player and give noclip
Reply With Quote #8

Quote:
Originally Posted by Xellath View Post
Include fun.
Compiling works now, but once I go to my menu it gives a fatal error

Heres my whole code:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>

public plugin_init() {
    
register_plugin("event""1.0""iPlayz")
    
register_clcmd("say /Event""Event")
    
register_clcmd("say_team /Event""Event")
    
}

public 
Event(id)
{
    new 
Event menu_create ("\r[`TEST]\wEvent Menu ^nBy \riPlayz\w^n""EventHandler")
        
        
menu_additem(Event"Aim player for NoClip""1"ADMIN_KICK)
        
menu_additem(Event"Aim player for GodMode""2"ADMIN_KICK)
        
menu_additem(Event"Aim player for Glow""3"ADMIN_KICK)
        
menu_additem(Event"Give NoClip""4"ADMIN_KICK)
        
menu_additem(Event"Give Godmode""5"ADMIN_KICK)
        
menu_additem(Event"Give Glow""6"ADMIN_KICK)
        
menu_additem(Event"Remove NoClip""7"ADMIN_KICK)
        
menu_additem(Event"Remove Godmode""8"ADMIN_KICK)
        
menu_additem(Event"Remove Glow""9"ADMIN_KICK)
        
menu_setprop(EventMPROP_EXITMEXIT_ALL)
        
menu_display(idEvent0)
}

public 
EventHandler(idmenuitem)
{
    if (
is_user_admin(id) && is_user_alive(id))

    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
data[6], name[64]
    new 
accesscallback
    
    menu_item_getinfo 
(menuitemaccessdata5name63callback)
    new 
key str_to_num (data)
    
    switch(
key)
    {
        case 
1:
        {
            
        }
        case 
2:
        {
            
        }
        case 
3:
        {
            
        }
        case 
4:
        {
            
set_task(0.0"GiveNoclip")
        }
        case 
5:
        {
            
set_task(0.0"GiveGodmode")
        }
        case 
6:
        {
            
set_task(0.0"GiveGlow")
        }
        case 
7:
        {
            
        }
        case 
8:
        {
            
        }
        case 
9:
        {
            
        }
        
    
    }
    return 
PLUGIN_CONTINUE
}

public 
GiveNoclip(id)
{
    new 
Players32 ], ClientNum_Num], Name32 ];
    
// retrieve all alive players
    
get_playersPlayersNum"a" );
    
    
// create menu
    
new Menu menu_create"Give Noclip to player:""NoclipMenuHandler" );
    for( new 
Index 0Index NumIndex++ )
    {
        
Client PlayersIndex ];
        
        
// get user name
        
get_user_nameClientNamecharsmaxName ) );
        
        
// convert player index to string
        
num_to_strClient_Numcharsmax_Num ) );
        
        
// add them to menu
        
menu_additemMenuName_Num );
    }
    
    
// display menu
    
menu_displayidMenu);
}

public 
NoclipMenuHandleridMenuItem )
{
    if( 
Item == MENU_EXIT )
    {
        
menu_destroyMenu );
        
        return;
    }
    
    new 
Info];
    new 
_AccessCallback;
    
// get key pressed
    
menu_item_getinfoMenuItem_AccessInfocharsmaxInfo ), __Callback );
    
menu_destroyMenu );
    
    
// set noclip to target index
    
set_user_noclipstr_to_numInfo ), );

iplayz is offline
Erox902
Veteran Member
Join Date: Jun 2009
Location: Never Never Land
Old 10-06-2011 , 12:42   Re: Targeting a player and give noclip
Reply With Quote #9

Wtf??

PHP Code:
switch(key
    { 
        case 
1
        { 
             
        } 
        case 
2
        { 
             
        } 
        case 
3
        { 
             
        } 
        case 
4
        { 
            
set_task(0.0"GiveNoclip"
        } 
        case 
5
        { 
            
set_task(0.0"GiveGodmode"
        } 
        case 
6
        { 
            
set_task(0.0"GiveGlow"
        } 
        case 
7
        { 
             
        } 
        case 
8
        { 
             
        } 
        case 
9
        { 
             
        } 
         
     
    } 
    return 
PLUGIN_CONTINUE 

Ofcourse it gives errors when you don't tell it what to do.
And why do you even use set_task()? set_user_godmode(), set_user_noclip() and set_user_rendering() exists for a reason
Also you cannot use set_task(0.0
0.01 is the absolute lowest you can use if I remeber correct.

----EDIT----
Okay did'nt scroll down far enough to see that you made a menu for the givenoclips and such, but still remove the set_tasks they are not needed and will not work when setted to 0.0

Last edited by Erox902; 10-06-2011 at 12:45.
Erox902 is offline
iplayz
Junior Member
Join Date: Oct 2011
Old 10-06-2011 , 17:01   Re: Targeting a player and give noclip
Reply With Quote #10

In matter of fact, 0.0 does work as I used it a several times...

+ u are not answering my question:/
iplayz 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 07:24.


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