Raised This Month: $51 Target: $400
 12% 

Using GetCmdArg in new ""


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 12-27-2013 , 14:29   Using GetCmdArg in new ""
Reply With Quote #1

Hi guys i've got some problem with my code
Here i'm trying to get command argument then create new variable that uses arg that i've grabbed as it's name
PHP Code:
public Action:CreateVar(args)
{
    
decl String:arg1[64];
    
GetCmdArg(1arg1sizeof(arg1))
    new 
arg1

So something like this:
PHP Code:
!createvar "Gaben" 
Would result in
PHP Code:
new Gaben 
- Help would be really helpful
- Thanks
__________________
...

Last edited by Oshizu; 12-27-2013 at 14:30.
Oshizu is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-27-2013 , 15:01   Re: Using GetCmdArg in new ""
Reply With Quote #2

impossible
Bacardi is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 12-27-2013 , 15:13   Re: Using GetCmdArg in new ""
Reply With Quote #3

You're trying to make an in-game command that changes the plugin's own coding?

wat
__________________
ddhoward is offline
SystematicMania
Senior Member
Join Date: Aug 2012
Old 12-27-2013 , 15:23   Re: Using GetCmdArg in new ""
Reply With Quote #4

A trie might work for your purposes. I can't know for sure unless you explain what you're planning to do.
__________________
SystematicMania is offline
Marcus_Brown001
AlliedModders Donor
Join Date: Nov 2012
Location: Illinois, United States
Old 12-27-2013 , 15:34   Re: Using GetCmdArg in new ""
Reply With Quote #5

That is not possible O.o. I don't know why you would need to do this ... when a plugin is running on a sever no one will see what the variables are called. You can assign the value "Gaben" to a variable, but you can't make a variable change its name to that argument. I think the simplest reason is that the plugin file the server runs is a binary file. You cannot edit it.
Marcus_Brown001 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-27-2013 , 16:26   Re: Using GetCmdArg in new ""
Reply With Quote #6

array+trie

sm_command "give name" number
sm_command
Bacardi is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 12-28-2013 , 02:18   Re: Using GetCmdArg in new ""
Reply With Quote #7

actually I think he looking to do something similar to eventscripts where variables are actually console commands (lol).

Last edited by Mathias.; 12-28-2013 at 02:18.
Mathias. is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 12-28-2013 , 02:31   Re: Using GetCmdArg in new ""
Reply With Quote #8

He is talking about Evaluation, which basically works only in dynamic languages. Some langs doing this by reflection, but neither of these are available in sourcemod.

So your best bet, as mentioned above - trie/hashmap.
xf117 is offline
Send a message via ICQ to xf117
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 12-28-2013 , 03:57   Re: Using GetCmdArg in new ""
Reply With Quote #9

Yeah trie seems to be the closest to what you'd be willing to do with a similar behaviour.

Code:
public Action:CreateVar(args)
{
    decl String:arg1[64];
    GetCmdArg(1, arg1, sizeof(arg1))
    new arg1
}
A small tip when coding, try to either always use ";" or never use it. You're using 2 different code style, which doesn't make sense.

If you want to enforce the use of semi-column u can use :

Code:
#pragma semicolon 1
In the header of your code, which will make sure you have ";" at the end of a SourcePawn instruction.

Red
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work
RedSword 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 13:21.


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