AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   pfn_use() is never called (https://forums.alliedmods.net/showthread.php?t=19639)

johnjg75 10-22-2005 00:45

pfn_use() is never called
 
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 }

GHW_Chronic 10-22-2005 00:47

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

XxAvalanchexX 10-22-2005 01:00

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.

PM 10-22-2005 06:11

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::PlayerUse 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::PlayerUse these days.

EDIT: Or maybe they provide it for bots.

XxAvalanchexX 10-22-2005 19:15

Then why do we still have the FM_Use forward available?

atomic 10-22-2005 19:18

i dont know... but maybe you should register it in the plugin_init?

Zenith77 10-22-2005 19:20

Its a forward.

PM 10-22-2005 20:40

Quote:

Originally Posted by XxAvalanchexX
Then why do we still have the FM_Use forward available?

To confuse people.

GHW_Chronic 10-23-2005 03:26

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.

KCE 10-24-2005 19:00

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 :wink:


All times are GMT -4. The time now is 23:43.

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