Raised This Month: $ Target: $400
 0% 

pfn_use() is never called


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
johnjg75
Veteran Member
Join Date: Mar 2004
Location: Delaware
Old 10-22-2005 , 00:45   pfn_use() is never called
Reply With Quote #1

I'm making a plugin where it makes it where a player cant drive from admin powers. I'm having one little problem tho trying to block them from driving. It revokes and unrevokes fine but it never actually blocks them from driving and i found out pfn_use() isnt being called because with my debug sayings, it says nothing at all. Does anyone know why it wont be called?

Code:
#include <amxmodx> #include <amxmisc> #include <engine> public plugin_init() {     register_plugin("License Handler","1.0","Johnjg75")     register_concmd("amx_revoke","revoke",ADMIN_KICK,"<player> - Revokes the player's license")     register_concmd("amx_unrevoke","unrevoke",ADMIN_KICK,"<player> - Renews a player's license")        } public pfn_use(user,used) {     client_print(0,print_chat,"LEVEL 0 REACHED") // level 0     //if(!is_valid_ent(user) || !is_valid_ent(used))         //return PLUGIN_CONTINUE         new entname[32]         entity_get_string(used,EV_SZ_targetname,entname,31)         if(strcmp(entname,"func_vehicle",1))         {                   new playerauth[40]             client_print(0,print_chat,"LEVEL 1 REACHED")// Level 1             get_user_authid(user,playerauth,39)             new vaultauth[50]             format(vaultauth,49,"RV%s",playerauth)             if(vaultdata_exists(vaultauth))             {                 client_print(0,print_chat,"LEVEL 2 REACHED") // Level 2                 return PLUGIN_HANDLED             }                         }             client_print(0,print_chat,"ERROR")         return PLUGIN_CONTINUE } public revoke(id) {     new playern[42]     read_argv(1,playern,41)     new playerid = find_player("b",playern)     if(!playerid)     {         client_print(id,print_console,"Sorry, this user is not found.")         return PLUGIN_CONTINUE     }     new playerauth[40]     get_user_authid(playerid,playerauth,39)     new vaultauth[50]     format(vaultauth,49,"RV%s",playerauth)     set_vaultdata(vaultauth,"1")     client_print(id,print_console,"Player's license revoked.")     return PLUGIN_CONTINUE } public unrevoke(id) {     new playern[42]     read_argv(1,playern,41)     new playerid = find_player("b",playern)     if(!playerid)     {         client_print(id,print_console,"Sorry, this user is not found.")         return PLUGIN_CONTINUE     }     new playerauth[40]     get_user_authid(playerid,playerauth,39)     new vaultauth[50]     format(vaultauth,49,"RV%s",playerauth)     if(!vaultdata_exists(vaultauth))     {         client_print(id,print_console,"Player's license was never revoked.")         return PLUGIN_CONTINUE     }     if(vaultdata_exists(vaultauth))     {         remove_vaultdata(vaultauth)         client_print(id,print_console,"This player's license was unrevoked.")         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE }
__________________
johnjg75 is offline
Send a message via AIM to johnjg75 Send a message via MSN to johnjg75 Send a message via Yahoo to johnjg75
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 10-22-2005 , 00:47  
Reply With Quote #2

sry johnjg75 but...
Quote:
Originally Posted by funcwiki
pfn_use
[ Main ] [ Engine ] [ engine.inc ]
[ comments ]

pfn_use - DEPRECATED. Called when an object uses another object.

Syntax:
public pfn_use ( user, used )
Type:
Forward
Notes:
This callback is DEPRECATED and is no longer available.

Returning PLUGIN_HANDLED will block the engine call.
Key word DEPRECATED as in the function doesnt work anymore
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-22-2005 , 01:00  
Reply With Quote #3

pfn_use is a hook equal to that of catching FM_Use with FakeMeta. Even that doesn't work, even though there is no real reason why it shouldn't. Unfortunately there is no real way to tell when an entity is used.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 10-22-2005 , 06:11  
Reply With Quote #4

Quote:
Originally Posted by XxAvalanchexX
Even that doesn't work, even though there is no real reason why it shouldn't. Unfortunately there is no real way to tell when an entity is used.
pfnUse is a member of the DLL_FUNCTIONS structure. This means that the engine can call pfnUse in the game DLL. But why on earth should the engine decide when an object uses an other one? That logic should be kept in the game dll. As I said several times, I think that this callback comes from older SDK versions where the engine still used to decide when an object is being used. In the latest HLSdk, use is handled in the DispatchUse function in cbase.cpp and in the CBasePlayer:layerUse function in player.cpp. I suspect that DispatchUse is never called (okay, it is called from plugins, but it's never called by the engine); the logic is done in CBasePlayer:layerUse these days.

EDIT: Or maybe they provide it for bots.
__________________
hello, i am pm
PM is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-22-2005 , 19:15  
Reply With Quote #5

Then why do we still have the FM_Use forward available?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
atomic
Veteran Member
Join Date: Jan 2005
Location: What The Foot?
Old 10-22-2005 , 19:18  
Reply With Quote #6

i dont know... but maybe you should register it in the plugin_init?
__________________
atomic is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-22-2005 , 19:20  
Reply With Quote #7

Its a forward.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 10-22-2005 , 20:40  
Reply With Quote #8

Quote:
Originally Posted by XxAvalanchexX
Then why do we still have the FM_Use forward available?
To confuse people.
__________________
hello, i am pm
PM is offline
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 10-23-2005 , 03:26  
Reply With Quote #9

Quote:
Originally Posted by PM
Quote:
Originally Posted by XxAvalanchexX
Then why do we still have the FM_Use forward available?
To confuse people.
Clearly.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
KCE
Senior Member
Join Date: Jan 2005
Location: Los Angeles, CA
Old 10-24-2005 , 19:00  
Reply With Quote #10

Here's a solution: What you can do is check in prethink if the player is looking at an entity and if he is pressing his use button. Unfortunately, you can't really block use perse, however you remove the use button from their buttons, so they won't be pressing it anymore.

Code:
public client_PreThink( id ) {     //if not alive, return     if ( !is_user_alive(id) )         return PLUGIN_CONTINUE         //if not pressing use button, return     if ( !(entity_get_int(id, EV_INT_button) & IN_USE)  )         return PLUGIN_CONTINUE     new aim_at_id, aim_at_body     //get_user_aiming ( index, &id, &body, [ distance ] )     get_user_aiming(id, aim_at_id, aim_at_body, 150)     //if not looking at anything, return     if ( !is_valid_ent(aim_at_id) )         return PLUGIN_CONTINUE                  //do whatever with aim_at_id, which is the ent, id is looking at     //in your case:         new entname[32]     entity_get_string(used, EV_SZ_targetname, entname,31)         if( !equal(entname,"func_vehicle") )         return PLUGIN_CONTINUE             new playerauth[40]     get_user_authid(user, playerauth, 39)     new vaultauth[50]     format(vaultauth, 49, "RV%s", playerauth)     //looks like here you wanted to block it since you used return PLUGIN_HANDLED     if( !vaultdata_exists(vaultauth) )     {         //remove the use button from their buttons         entity_set_int( id, EV_INT_button, entity_get_int(id, EV_INT_button) & ~IN_USE )         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE }

Me want Karma
KCE is offline
Reply


Thread Tools
Display Modes

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 23:43.


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