Show Posts
|
|
Pages: [1]
|
|
1
|
Scripting / Script Help / Re: Help with .ini
|
on: November 24, 2012, 10:07:26 am
|
Thanks! But if I want more languages?
I use this?:
local fra = GetTok( Lang1, ";", 2 );
Yeah. Another thing: what if I want variables in those messages? for example
"Bienvenido al server, " + plr "Welcome to the server, " + plr You would just have to extract the text from the ini and then attach the player's name/whatever to it in a callback such as onPlayerJoin.
|
|
|
|
|
3
|
Scripting / Script Help / Re: Say please how to make command on type /command [ID] [Amount] (for VBS)
|
on: August 27, 2012, 12:59:38 pm
|
|
I don't know what VBS looks like but it's very simple in general. You firstly need a tokenization function.
What are tokens? Tokens are strings of anything separated by something. For example, the sentence "Hello World" has two tokens - "Hello" and "World", split by a single space (" "). The weapon command will go the same way. You will have an ID token and an ammo token.
Here's the tokenization function:
function GetTok(string, separator, n, ...) { local m = vargv.len() > 0 ? vargv[0] : n, tokenized = split(string, separator), text = ""; if (n > tokenized.len() || n < 1) return null; for (; n <= m; n++) { text += text == "" ? tokenized[n-1] : separator + tokenized[n-1]; } return text; } (Credits go to Force)
All that is left now is to make a weapon command.
else if( command == "wep" || command == "weapon" ) { if( !text ) MessagePlayer( "Error - the syntax is /we(a)p(on) <ID> <Ammo>", player ); else { local ID = GetTok( text, " ", 1 ), // The first token which comes after the command's name, separated by a space (" ") ammo = GetTok( text, " ", 2 ); // The second token which comes after the ID, again separated by a space (" " ) if( IsNum( ID ) ) // Assuming you only want IDs to be used in your command, we will only accept digits { ID = ID.tointeger(); // Convert to an integer ammo = ammo.tointeger(); // Convert to an integer player.SetWeapon( ID, ammo ); // Success local msg = format( "Successfully given a %s with %d ammo.", GetWeaponName( ID ), ammo ); // Pre-formatting messages is always nice. MessagePlayer( msg, player ); } else MessagePlayer( "The first parameter needs to be a digit.", player ); } Have a nice day.
|
|
|
|
|
4
|
Scripting / Script Help / Re: Help in command /setskin correction.
|
on: August 26, 2012, 11:00:59 am
|
else if ( cmd == "setskin" )
local skin = text ? text.tointeger() : 0; } What not so in a command? Help to correct.
Why make life such a pain? Do you even know what the "?" closure is used for? I highly doubt it. You should replace what I quoted above with the following: local skin = text.tointeger();However, I'd suggest you to not convert the "skin" variable to an integer right away, rather first check whether the skin parameter a player on your server will type is a digit by using IsNum, and if it is, convert it to an integer. Have a nice day.
|
|
|
|
|