Author Topic: Changing var from console  (Read 1291 times)

0 Members and 1 Guest are viewing this topic.

Offline Vyka

  • Major
  • *
  • Posts: 59
Changing var from console
« on: August 19, 2008, 04:44:51 pm »
Hi Guys.
I need help (script ;P ), can somebody tell me, how to change var (shortint) from console?

the best way will be something like that

/change var

for example
/change 1
and var is changing to 1.

how to do this, i need it in my new script, please, help ;)
« Last Edit: August 19, 2008, 05:06:44 pm by Vyka »

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: Changing var from console
« Reply #1 on: August 19, 2008, 05:11:36 pm »
u mean, change a variable in a script?

Offline Vyka

  • Major
  • *
  • Posts: 59
Re: Changing var from console
« Reply #2 on: August 19, 2008, 05:15:02 pm »
yes, can you help me?  :)

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: Changing var from console
« Reply #3 on: August 19, 2008, 05:22:34 pm »
depends
so you want to change a value of some variable, to a diffrent value right?
then you need to specyfiy the name of the variable
like /change <varname> <value>
well.... it is possible, but im not expirienced that much. i would make it, but i dont know how to check if the variable exists

Offline Vyka

  • Major
  • *
  • Posts: 59
Re: Changing var from console
« Reply #4 on: August 19, 2008, 05:26:14 pm »
that won't work, have you got another idea?

btw. i need a part of script.
« Last Edit: August 19, 2008, 05:29:49 pm by Vyka »

Offline rayanaga

  • Soldier
  • **
  • Posts: 143
  • ~Fur flying~
    • Kryonex
Re: Changing var from console
« Reply #5 on: August 19, 2008, 06:10:22 pm »
You could try a custom admin command on procedure

Code: [Select]
function OnCommand(ID: Byte; Text: string): boolean;
[kY] Kryonex - Your local zombie fanatics.
http://www.kryonex.com/

Offline lewymati

  • Major(1)
  • Posts: 38
Re: Changing var from console
« Reply #6 on: August 20, 2008, 06:53:47 am »
guys, u all fail...
There's no function which could get the pointer to the whichever variable from string, there isnt anything like "changevariable(variable:string,newvalue:sometype)"...

If you have only some variable to change and u know which are they u can do it like that:

Code: [Select]
var
smth:integer;
smth2:integer;

(...)

function OnCommand(ID: Byte; Text: string): boolean;
begin
        case LowerCase(GetPiece(Text,' ',0)) of
          '/change':
               case LowerCase(GetPiece(Text,' ',1)) of
                 'smth': smth:=strtoint(GetPiece(Text,' ',2));
                 'smth2': smth2:=strtoint(GetPiece(Text,' ',2));
          end;

        end;
Result := false;
end;


(...)
I didnt compile that code, just get the spirit :)

Offline Vyka

  • Major
  • *
  • Posts: 59
Re: Changing var from console
« Reply #7 on: August 20, 2008, 03:20:12 pm »
thanks a lot :) but it doesnt work.

i used

Code: [Select]
if RegExpMatch('^/ktkchange \d+$', Text) then
begin
ilosc:=StrToInt(GetPiece(Text, ' ', 1));
        end;
« Last Edit: August 20, 2008, 05:03:04 pm by Vyka »

Offline rayanaga

  • Soldier
  • **
  • Posts: 143
  • ~Fur flying~
    • Kryonex
Re: Changing var from console
« Reply #8 on: August 21, 2008, 06:55:01 pm »
guys, u all fail...
There's no function which could get the pointer to the whichever variable from string, there isnt anything like "changevariable(variable:string,newvalue:sometype)"...

If you have only some variable to change and u know which are they u can do it like that:

Code: [Select]
var
smth:integer;
smth2:integer;

(...)

function OnCommand(ID: Byte; Text: string): boolean;
begin
        case LowerCase(GetPiece(Text,' ',0)) of
          '/change':
               case LowerCase(GetPiece(Text,' ',1)) of
                 'smth': smth:=strtoint(GetPiece(Text,' ',2));
                 'smth2': smth2:=strtoint(GetPiece(Text,' ',2));
          end;

        end;
Result := false;
end;


(...)
I didnt compile that code, just get the spirit :)
You could try a custom admin command on procedure

Code: [Select]
function OnCommand(ID: Byte; Text: string): boolean;

Isn't that what i just suggested?
[kY] Kryonex - Your local zombie fanatics.
http://www.kryonex.com/