Raised This Month: $ Target: $400
 0% 

Solved Storing Console Cmds in Variable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-20-2016 , 14:21   Storing Console Cmds in Variable
Reply With Quote #1

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...

Last edited by hellmonja; 06-25-2017 at 04:21. Reason: Solved...
hellmonja is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 05-20-2016 , 14:50   Re: [HELP] Storing Console Cmds in Variable
Reply With Quote #2

Sure it does.
Describe what you are trying to do exatcly.
SpeeDeeR is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-20-2016 , 15:06   Re: [HELP] Storing Console Cmds in Variable
Reply With Quote #3

Quote:
Originally Posted by SpeeDeeR View Post
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...
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-20-2016 , 15:14   Re: [HELP] Storing Console Cmds in Variable
Reply With Quote #4

Then save the command in a string when it's executed, lol.
__________________
HamletEagle is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-20-2016 , 15:34   Re: [HELP] Storing Console Cmds in Variable
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
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 is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-21-2016 , 04:09   Re: [HELP] Storing Console Cmds in Variable
Reply With Quote #6

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...
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-21-2016 , 06:13   Re: [HELP] Storing Console Cmds in Variable
Reply With Quote #7

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.
__________________

Last edited by HamletEagle; 05-21-2016 at 06:17.
HamletEagle is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-21-2016 , 09:38   Re: [HELP] Storing Console Cmds in Variable
Reply With Quote #8

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...

Last edited by hellmonja; 05-21-2016 at 09:41.
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-21-2016 , 09:50   Re: [HELP] Storing Console Cmds in Variable
Reply With Quote #9

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.
__________________

Last edited by HamletEagle; 05-21-2016 at 09:50.
HamletEagle is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 05-21-2016 , 10:01   Re: [HELP] Storing Console Cmds in Variable
Reply With Quote #10

Quote:
Originally Posted by HamletEagle View Post
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?...

Last edited by hellmonja; 05-21-2016 at 10:03.
hellmonja is offline
Reply



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 18:34.


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