AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Command accepting partial names? (https://forums.alliedmods.net/showthread.php?t=5590)

twistedeuphoria 09-06-2004 02:11

Command accepting partial names?
 
How can I get a command to accept partial names? This is my code so far:
Code:
public changeboost(id) {     if(! get_user_flags(id) && ADMIN_KICK)         return PLUGIN_HANDLED     new target[31]     new boost[20]     new tgtid     new boostamo     read_argv(1,target,30)     read_argv(2,boost,19)     tgtid = get_user_index(target)     boostamo = str_to_num(boost)     if(boostamo < 0)         boostamo = 0     boostamount[tgtid] = boostamo     return PLUGIN_HANDLED }
Thank you for your time.

BAILOPAN 09-06-2004 02:40

Use cmd_target()

twistedeuphoria 09-06-2004 02:59

Like this?
Code:
public changeboost(id) {     if(! get_user_flags(id) && ADMIN_KICK)         return PLUGIN_HANDLED     new target[31]     new boost[20]     new tgtid     new boostamo     read_argv(1,target,30)     new player = cmd_target(id,target,1)     if(!player) return PLUGIN_HANDLED     read_argv(2,boost,19)     tgtid = get_user_index(target)     boostamo = str_to_num(boost)     if(boostamo < 0)         boostamo = 0     boostamount[tgtid] = boostamo     return PLUGIN_HANDLED }

Votorx 09-06-2004 04:19

Yes but player is now that player's id. so you don't need to do tgtid = get_user_index(target)

twistedeuphoria 09-06-2004 15:07

Thanks, but for some reason when you use it on someone it says invalid command. It does the command, but it prints invalid command in console.

Edit: Nvm I got it thanks guys.


All times are GMT -4. The time now is 17:24.

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