AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [ANY] playerpicker.inc (https://forums.alliedmods.net/showthread.php?t=342094)

reBane 03-07-2023 13:46

[ANY] playerpicker.inc
 
Hi, i wrote this inc file for targeted commands (/example @me). If the target is not found or no target was specified, this script can open a menu to the client, to pick a player from a list using PickPlayer().
There is an example in the gist, that might be outdated, but it should be a good reference.

Actual usage would be:
PHP Code:

void callback(int resultint userid) {
    
int client GetClientOfUserId(userid);
    if (!
client || !result) return; //result 0 = cancelled by user/menu timeout
    
if (result 0PrintToChat(client"Target error"); // <0 are target COMMAND_TARGET_* values
    
doWhatever(result); //result = client index
}
//...
    
PickPlayer(clientCOMMAND_FILTER_*, callbackGetClientUserId(client)); 

https://gist.github.com/DosMike/d8c3...09d845e113877a

Grey83 03-08-2023 06:48

Re: [ANY] playerpicker.inc
 
1 Attachment(s)
Why don't you use this function?
int AddTargetsToMenu2(Handle menu, int source_client, int flags)

reBane 03-08-2023 07:24

Re: [ANY] playerpicker.inc
 
There's a lot of natives, and sometimes I'll just spend some minutes writing a loop over spending some minutes of searching for the perfect native. Thanks for pointing that out, I'll update the gist when i get home :)


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

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