Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - .
Snippet Showroom / Re: Team System v1.0.1
« on October 28th, 2014, 11:21 PM »
NOTE: This is untested code! If you use this please make sure to test it first.

Code: [Select]
// Moved to PasteBin to preserve formatting:
Quick Tip: There's no need to create a vector object just to pass it as an argument. The function is overloaded to also accept three floating point values that form a position. Therefore you could pass those values directly.

Optimization Tip: Why do you call the tofloat() member function on each position variable? They'll get converted automatically so you don't have to make three function calls for nothing. Doing this on numerical values is a waste of instructions for the function call.

The error messages simply states that it couldn't find a function (overloaded or not) matching the arguments you provided. Basically you need to look at what arguments the function is expecting and what arguments are you passing.

There's also a possibility that the error isn't even coming from function call but rather from the vector constructor. So make sure to check that too.

One more thing that you could do is document on how the execution context works in Squirrel (as suggested by Thijn). I got fooled a couple of times by this my self by simply forgetting about it :D
Snippet Showroom / Re: Team System
« on October 27th, 2014, 06:46 PM »
Quote from KraTO$ on October 27th, 2014, 06:25 PM
Which plugins contains time(). Function?
It's built into the Squirrel standard library.
Snippet Showroom / Re: Team System
« on October 27th, 2014, 01:26 AM »
Quote from KraTO$ on October 26th, 2014, 06:11 PM
I told the Specific Line already -_-
No you haven't! Not even the provided error message seems to be correct. Call "integer" where?... maybe "tointeger". I haven't looked at the code but based on the error message you provided the code is trying to use a variable of integer data type as a function. At least that's what I understand from that message. Because I don't see a function/method named "integer" being called.

Learn to provide the proper information to the author so that he won't have to waste 10-20 posts just to get one simple information such as
  • line number(s) (maybe even column if possible)
  • actual error message with as much debug information as possible
  • circumstances under which the code was used (step by step)
  • was there any other code involved? (maybe it's your code failing)
  • sometimes even actual screenshots of the console output
  • server and used plugin versions
  • details... details... details...
Snippet Showroom / Re: Hotkeys system :)
« on October 24th, 2014, 09:29 PM »
You should have posted the email directly because it's more descriptive on the whole process ;D (untested though)
Sorry for the late reply but I haven't visited my email in a while. In vcmp 0.4 you bind a key using the BindKey() function:

Code: [Select]
BindKey(boolean [down: true = press, false = release], integer [key1: ], integer [key2: ], integer [key3: ]);
Note: You can also insert the hex value directly because Squirrel will convert it to integer automatically.

The first parameter tells whether you are binding for the press event instead of the release event. Since it's a boolean if you pass true then it'll create a keybind for the press event and false does the opposite by creating a keybind for the release event.

The three remaining integer parameters represent the unique number (aka the keycode) of the button on the keyboard that you wish to bind to. You can bind to three buttons primary, secondary and alternative.

When you successfully bind a key you get another unique ID which represents the event that you just created. Using that ID you can identify whether the key you binded was used or not. (If the binding fails then you'll receive null as the return value)

If you binded for the release event of a button on the keyboard then you'll receive your events through the onKeyUp() function which has the following signature:

Code: [Select]
onKeyUp(instance [player: ], integer [bind_id: ]);

If you binded for the press event of a button on the keyboard then you'll receive your events through the onKeyDown() function which has the following signature:

Code: [Select]
onKeyDown(instance [player: ], integer [bind_id: ]);

The first parameter is an instance of the player who pressed the key. And the second parameter is the unique ID which you received as a return value previously from the BindKey() function. That's how you identify what key that player pressed.

The following snipped should illustrate what I mean:

Code: [Select]
// Somewhere to store the returned keybind id
local my_bind = null;
function onServerStart()
// Bind for the press event of a keyboard button
my_bind = BindKey(true, 0x50);
// Note: the 0x50 is the keycode for the <P> keyboard button
function onKeyDown(player, bind_id)
// If the bind id matches our bind id then we know the player
// pressed his <P> keyboard button
if (bind_id == my_bind) {
print("You pressed the P keyboard button.");

I might be incorrect about it because nobody documented anything. I just looked at the Squirrel source code and to see how it works. If this is incorrect then you should ask on the forum. Maybe someone from the staff will clear this out.