AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Storing Console Cmds in Variable (https://forums.alliedmods.net/showthread.php?t=282913)

hellmonja 05-20-2016 14:21

Storing Console Cmds in Variable
 
Is there a way to store a command entered on the console, store that command into a string variable and do stuff with it? Like compare it with other string or forcing it to be executed again? Last time I checked, if I remember correctly, PAWN doesn't handle strings...

SpeeDeeR 05-20-2016 14:50

Re: [HELP] Storing Console Cmds in Variable
 
Sure it does.
Describe what you are trying to do exatcly.

hellmonja 05-20-2016 15:06

Re: [HELP] Storing Console Cmds in Variable
 
Quote:

Originally Posted by SpeeDeeR (Post 2420539)
Sure it does.
Describe what you are trying to do exatcly.

Well, I have created more than 20 extra weapons for CS 1.6, not ZP, just CS. And they're all called by registering 'concmd'. I'm trying to make my own rebuy plugin and I figured, if I could take the command, compare it to a list of sort then i can store that command for use later when I execute my own rebuy...

HamletEagle 05-20-2016 15:14

Re: [HELP] Storing Console Cmds in Variable
 
Then save the command in a string when it's executed, lol.

hellmonja 05-20-2016 15:34

Re: [HELP] Storing Console Cmds in Variable
 
Quote:

Originally Posted by HamletEagle (Post 2420546)
Then save the command in a string when it's executed, lol.

Really? Huh, must've been reading the wrong stuff.
http://amxmodx.org/doc/index.html?pa...g%2Fprimer.htm

Last time I attempted this plugin I was having problems with a mismatched data type or something.
I'll give it a go at it first and see what I come up with...

hellmonja 05-21-2016 04:09

Re: [HELP] Storing Console Cmds in Variable
 
Ok, I really don't know how to retrieve the concmd for use. I dabbled with the get_concmd but it seems I'm in the wrong track, or maybe not using it correctly. The thing's got sooooo many parameters...

HamletEagle 05-21-2016 06:13

Re: [HELP] Storing Console Cmds in Variable
 
Lol, lol, lol.

You are registering the commands, right? Then you know what command is called. Simply use copy(string, charsmax(string), "cmd_name") in the corresponding public.

hellmonja 05-21-2016 09:38

Re: [HELP] Storing Console Cmds in Variable
 
I uh, I know may sound stupid but I can't get it to work. Here's what I have:
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "RePurchase"
#define VERSION "1.0"
#define AUTHOR "Hell"

new Pri_Wpn[33], Sec_Wpn[33], g_HE[33], g_Smoke[33], g_Def[33], g_NVGS[33], g_Molotovg_Vestg_VestHelm
new string[33][32];

new 
Primary[33][] = 
{
     
"m3""xm1014""mp5""tmp""p90""mac10""ump45""ak47""galil""famas""sg552""m4a1""aug""scout",
     
"awp""g3sg1""sg550""m249""shield""12gauge""autoshotgun""smg""mp""c90""cv47""defender",
     
"clarion""krieg552""bullpup""magnum""d3au1""krieg550""sawedoff""supershorty""usas12" "skorpion",
     
"mp7""bizon""vector""uzi""tavor""scarl""g36""groza""xm8""snake""m60""vulcan""sl8""wa2000",
     
"bow"
}

new 
Secondary[33][] = 
{
     
"usp""glock""deagle""p228""elites""fn57""km45""9x19mm""nighthawk""228compact""fiveseven",
     
"m1911a1""makarov""vp70""ragingbull""m29"
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
//    register_event("HLTV", "Event_New_Round", "a", "1=0", "2=0")
    
    
for (new isizeof Primaryi++)
        
register_clcmd(Primary[i], "ClientCommandBuyPrimary")
    
//    for (new i; i < sizeof Secondary; i++)
//        register_clcmd(Secondary[i], "BlockBuyCommands")
    
    
register_concmd("repurchase""ClientCommandRepurchase")
    
}

public 
ClientCommandBuyPrimary(id)
{
    
copystring[id], charsmax(string[]), Primary 
    
client_print(idprint_chat"Command: %s"string[id]);
    
Pri_Wpn[id][?] = string[id][10];
    
}
public 
ClientCommandRepurchase(id)
{
    
client_cmd(idPri_Wpn[id])


I know, it's still pretty much a mess but let try to explain the idea of it. Primary[] and Secondary[] holds all of the console commands for buying weapons, including my custom ones. I figured registering all Primaries in one public then when someone buys a rifle that matches one of the commands stores it in 'string' so I can use it. The retrieving a and storing part is what I'm having problems.

Sorry, I'm really trying not to turn this into a spoon-feeding session but I find I work best thru examples and so far I can't find a code where this is done...

HamletEagle 05-21-2016 09:50

Re: [HELP] Storing Console Cmds in Variable
 
Ah, it's like that, I was thinking you have different publics for each command.
Then, probably your best bet is using client_command forward since it pass command name.

hellmonja 05-21-2016 10:01

Re: [HELP] Storing Console Cmds in Variable
 
Quote:

Originally Posted by HamletEagle (Post 2420743)
Ah, it's like that, I was thinking you have different publics for each command.
Then, probably your best bet is using client_command forward since it pass command name.

I was actually thinking of using different publics but with more than 20 weapons added I figured this would be more, uh, elegant is the word I guess. I'd probably use it as a last resort, which at this point is likely to happen anyway since I can't wrap my head on how to do this yet...

Sooooo, I should register a forward, like this?
PHP Code:

register_forward(client_command"ClientCommandBuyPrimary"

And put my code in there?...


All times are GMT -4. The time now is 18:34.

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