Page 1 of 4
cvar question..
Posted: Sun Jan 25, 2009 12:04 pm
by SilentAngel
someone knows if there's a cvar "nextmap"?
I need to make a getcvar to results the name of the next map of map list..
Posted: Sun Jan 25, 2009 6:41 pm
by $oldier Of Ra
Yes the cvar "nextmap" holds the mapname of the next map. But it is not used on servers so it is actually useless to you.
Why do you need it anyways? There are a lot of "Next map" displaying scripts.
If you don't want to display it and only want the name then use this:
Code: Select all
//**********************************************
// get the name of the next map in line
//**********************************************
get_nextmap:
local.maplist = (getcvar "sv_maplist")
local.map = waitthread split_line local.maplist 1 " "
local.mapscript = waitthread to_lower (getcvar "mapname")
for (local.i = 1; local.i <= local.map[1].size; local.i++)
{
if (local.map[1][local.i] == local.mapscript)
{
local.f = (local.i + 1)
if (local.f > local.map[1].size)
{
local.f = 1
}
local.match = 1
local.nextmap = local.map[1][local.f]
end local.nextmap
}
}
if (local.match != 1)
{
end NIL
}
end
// The next two threads are
// from Elgan's strings.scr
// ---------------------------------------------------------------------------------
// Used to split a line of words into a array of words. return with word count
// localinfo == line to split
// local.say = say to admins input detected or not, set 1 usualy
// local.spacer = What to use to split the line. If none is set then " " will be used.
// usage local.wordarray = waitexec global/strings.scr::split_line ( STRING STRING, FEEDBACK, STRING SPACER)
//
//eg
// local.wordarray = waitexec global/strings.scr::split_line "hello_mummy" 1 "_"
// local.wordarray is a const array
//
// local.wordarray[1] = array of words
// local.wordarray[2] word count
// local.wordarray[3] full string with " " spaces
//
// local.wordarray[1][1] is 'hello'
// local.wordarray[1][1] is 'mummy'
//
// local.wordarray[2] is 2 'two words'
//
// local.wordarray[3] is 'hello mummy'
// ---------------------------------------------------------------------------------
split_line local.info local.dont_say local.spacer:
local.wordcount = 1
if(local.spacer==NIL)
{
if(local.info[0] == "`")
{
local.spacer = "_"
local.start = 1
}
else if(local.info[0] == " " || local.info[0] == "")
{
local.spacer = " "
for(local.i = 0;local.i <= local.info.size;local.i++)
{
if(local.info[local.i] != " " && local.info[local.i] != "")
{
local.start = local.i
break
}
}
}
else
{
local.spacer = " "
local.start = 0
}
}
else
{
local.start = 0
local.altcheck = 1
}
for(local.i=local.start;local.i<=local.info.size - 1;local.i++)
{
if(local.info[local.i]!=local.spacer && local.info[local.i] != "`")
{
if(local.words[local.wordcount]==NIL)
{
local.words[local.wordcount]=""
}
local.words[local.wordcount] += local.info[local.i]
}
else
{
if(local.altcheck != 1)
{
if(local.spacer == "_" && local.info[local.i + 1] == "`")
{
local.words[local.wordcount] += local.info[local.i]
}
else if(local.spacer == "_" && local.info[local.i ] != "`")
{
local.wordcount++
}
else if(local.spacer == " " && local.info[local.i ] == " ")
{
if(local.i != local.info.size - 1)
{
if(local.info[local.i + 1] != " " && local.info[local.i + 1] != NIL)
{
local.wordcount++
}
}
}
}
else
{
if(local.info[local.i ] == local.spacer)
{
local.wordcount++
}
}
}
}
if(local.spacer == "_")
{
local.actual = ""
for(local.i=3;local.i<=local.words.size;local.i++)
{
if(local.i < local.words.size)
{
local.space = " "
}
else
{
local.space = ""
}
local.actual += ( local.words[local.i] + local.space )
}
if(local.dont_say != 1)
{
//exec global/ac/console_feedback.scr ( "> Input detected: " + local.actual )
}
}
else
{
if(local.dont_say != 1)
{
//exec global/ac/console_feedback.scr ( "> Input detected: " + local.info)
local.actual = local.info
}
}
end ( local.words::local.wordcount::local.actual)
// --------------------------------------------------------------------------
// to_lower
// This will convert a given string to lower case
// usage local.string = waitexec global/strings.scr::to_lower (STRING STRING, INDEX TO CONVERT)
// Result: a lower case string
//
//eg
// local.string = waitexec global/strings.scr::to_lower "HELLO"
// local.string will become 'hello'
//eg2
// local.string = waitexec global/strings.scr::to_lower "HELLO" 0
// local.string will become 'hELLO'
// --------------------------------------------------------------------------
to_lower local.string local.index:
local.lower = waitthread chardata_lowercase
local.upper = waitthread chardata_uppercase
for(local.i = 0; local.i <= local.string.size - 1; local.i++)
{
local.letter = local.string[local.i]
if(local.i == local.index || local.index == NIL)
{
for(local.t = 1; local.t <= local.upper.size; local.t++)
{
if(local.letter == local.upper[local.t])
{
local.letter = local.lower[local.t]
local.string[local.i] = local.letter
}
}
}
else
{
local.string[local.i] = local.letter
}
}
end local.string
Posted: Mon Jan 26, 2009 12:34 pm
by SilentAngel
I'm trying to make the malta map select different scr to run differtents mods..
for exemple...if next map is stalingrad the map will run mp_malta_dm1.scr
and if the next map is mohdm2 it will run mp_malta_dm2.scr .
that's all..
I've put a script before prespown that select differents malta scr...but i'm having problems..

Posted: Mon Jan 26, 2009 3:59 pm
by $oldier Of Ra
Well just place what I posted above in a seperate script or in your malta script and the result will be the nextmap. Like so:
Code: Select all
local.o = waitthread global/a_script.scr::get_nextmap
or (if you placed it in your malta script)
Then local.o will contain the string of the next map.
Posted: Mon Jan 26, 2009 7:17 pm
by SilentAngel
yep..
thanks for the help..
Posted: Tue Feb 03, 2009 2:16 pm
by SilentAngel
I have to insert a new keyboard 's key to active a thread when pressed...
Code: Select all
someting like that:
if (O){
thread thread1
}
if (L){
thread thread2
}
in this case I've used keys O and L for an exemple..but I bunno what to put in ()....I had a look at all classies list but most of them are unknown to me..I'm still a newbie...lol
advices??

Posted: Tue Feb 03, 2009 3:49 pm
by $oldier Of Ra
It is quite impossible to detect when a key is pressed. Besides, you cannot execute any scripts in a server you don't host (I can't imagine what would happen if that was possible). If you do host the server yourself, you can do this through cvar input in the console.
Posted: Tue Feb 03, 2009 4:23 pm
by SilentAngel
I host it on my own..
however, do you know how to set it using cvars?
Posted: Tue Feb 03, 2009 7:25 pm
by $oldier Of Ra
Run this thread first:
Code: Select all
sth:
setcvar "mycvar" ""
while(1)
{
if ( (getcvar "mycvar") != "")
{
local.t = (getcvar "mycvar")
setcvar "mycvar" ""
thread local.t
}
wait 0.3
}
end
Then use in the console:
mycvar thread1
or
mycvar thread2
Change the mycvar to anything you want, but edit all instances of it in that lil' script.
Posted: Tue Feb 03, 2009 7:57 pm
by SilentAngel
hummmm..I still don't understead...using this one i set a cvar, but the problem is the cvar itself..I'm looking at cvar list but I don't understeand what to do..
how can I use cvars to set the use of a key such as "A", "B", ecc...?!
there should be an already existent one that set the use of a certain key....something like that:
man...I don't really understeand how cvars works....
also I've founded these 2: ..i never used them..maybe these can be useful to me...
Code: Select all
getboundkey1( String keyname )
return a string describing the key
getboundkey2( String keyname )
return a string describing the key
Posted: Wed Feb 04, 2009 11:15 am
by $oldier Of Ra
hummmm..I still don't understead...using this one i set a cvar, but the problem is the cvar itself..I'm looking at cvar list but I don't understeand what to do..
You shouldn't be looking in the cvar list because:
1. They are internal and are handled by the engine. You cannot change them to your will.
2. They cannot detect anything
3. None of them are any help to you
4. They just contain data in the form of strings
That's why I made a new cvar and a script which handles it like you want it to.
there should be an already existent one that set the use of a certain key....something like that:
You mean the keybinds? Well, why don't you try it hehe
I'm sure that'll work!
Go to main/configs/unnamedsoldier.cfg and add something like this:
Then press e ingame to see the results!
also I've founded these 2: ..i never used them..maybe these can be useful to me...
getboundkey1 and getboundkey2 are used to return the string of the key binded to the specified action. In other words, not to detect when a key is pressed. Besides, it only works properly in SP. Since it only checks the host/server binds. They can return "Enter" or "f" for "+use". Completely irrelevant to you.
man...I don't really understeand how cvars works....
I already explained how to use it in my previous post.
Make sure that script is running and located in the mapscript of your map and enter this is the console: "mycvar mythread". Where "mycvar" is the cvar handled in the script I posted earlier and "mythread" the name of the thread you want to activate.
I already gave you the perfect solution to your problem. Did you even bother to try it??
Posted: Wed Feb 04, 2009 12:17 pm
by SilentAngel
okay man..ty very much..I'll try now and post the results...

Posted: Wed Feb 04, 2009 10:39 pm
by Rookie One.pl
SoA, you should've made it clearer that the first part of your post was sarcastic, because apparently SilentAngel took it seriously.

Posted: Wed Feb 04, 2009 11:01 pm
by $oldier Of Ra
Well I get annoyed when my efforts in helping people get ignored. It's only natural.
So the keybind text was sarcastic, if that way had worked then I would have suggested it.
But I can make my solution even fancier by letting him pass variables through the console to the thread he wants to activate.

Posted: Thu Feb 05, 2009 2:04 pm
by SilentAngel
to add keys to do what i'm doing there's no need of cvars..just add bind a "what it as to do" in the autoexec.cfg.....
that's all.. tested and works...