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.

Topics - Sebastian
1
Videos & Screenshots / [dRiFt] Sebastian x Megamind
« on October 6th, 12:30 AM »
2
Tutorials / Record cool frames, all alone!
« on October 3rd, 11:58 AM »
Here is a short tutorial where I show and explain how you can record yourself,
from different angle, like somebody else is recording you !

There is no big deal, actually, but you can take one of the best frames. ;)
Keep Drifting! video was recorded just like that.

Long story, short ?
Just run 2 instances of VC:MP, in windowed mode, and start (fraps?) recording from the one with different angle.
Then return to your first screen where you have full control, and do your magic


3
Vehicle Showroom / [cuban] Drifting Handling
« on October 3rd, 11:02 AM »

While I was working on the Hydraulics' Alternative, I've found some handling settings that improve Cuban's Drifting ability.
In the past, I've used only downloaded handling - but now, I got my own.

Why is mine better than others' ? Because mine can be used in any type of server. (even RPG)
It's not based on increasing speed to the vehicle, so it will not look out of space.
It fits any background!

(click to show/hide)
Code: [Select]
<?xml version="1.0" encoding="ASCII"?>
<vehicle>
<basic>
<type>car</type>
<name>Cuban Hermes</name>
<anims>null</anims>
<comprules>0</comprules>
<extraflags>0010</extraflags>
<wheelmodel>253</wheelmodel>
<wheelscale>0.700000</wheelscale>
<immunity>0</immunity>
</basic>

<aidata>
<class>ignore</class>
<freq>10</freq>
<level>7</level>
</aidata>

<colors>
<carcol>1,1</carcol>
</colors>

<audio>
<enginefarsample>273</enginefarsample>
<enginenearsample>9</enginenearsample>
<hornsample>0</hornsample>
<hornfreq>25400</hornfreq>
<sirensample>0</sirensample>
<sirenfreq>9800</sirenfreq>
<doorsounds>0</doorsounds>
</audio>

<handling>
<mass>2150.000000</mass>
<percentsubmerged>75</percentsubmerged>
<steeringlock>40.000000</steeringlock>
<seatoffset>0.260000</seatoffset>
<damagemultiplier>0.550000</damagemultiplier>
<value>10000</value>
<flags>00000102</flags>

<dimensions>
<x>2.100000</x>
<y>5.000000</y>
<z>2.200000</z>
</dimensions>

<centreofmass>
<x>0.000000</x>
<y>0.000000</y>
<z>0.200000</z>
</centreofmass>

<traction>
<multiplier>0.750000</multiplier>
<loss>0.750000</loss>
<bias>0.530000</bias>
</traction>

<transmission>
<numofgears>5</numofgears>
<maxspeed>160.000000</maxspeed>
<acceleration>25.000000</acceleration>
<drivetype>4</drivetype>
<enginetype>P</enginetype>
</transmission>

<brakes>
<deceleration>6.000000</deceleration>
<bias>0.540000</bias>
<abs>0</abs>
</brakes>

<suspension>
<forcelevel>0.800000</forcelevel>
<dampening>0.080000</dampening>
<upperlimit>0.250000</upperlimit>
<lowerlimit>-0.260000</lowerlimit>
<bias>0.500000</bias>
<antidive>0.450000</antidive>
</suspension>

<lights>
<front>1</front>
<rear>1</rear>
</lights>
</handling>

</vehicle>

+

Code: [Select]
vehicle.SetHandlingData( 9, 0.5 ); // Traction Multiplier
vehicle.SetHandlingData( 11, 0.6 ); // Traction Bias
vehicle.SetHandlingData( 14, 30 ); // Acceleration
vehicle.SetHandlingData( 17, 40 ); // Brake Deceleration

PS: For the bridge neons, credits go to @PerikiyoXD !
4
REUPLOADED! jump to min1 - boring introduction

Playing with handlings, I got some good drifting one and started to play.
Wanted to check other players' videos about drifting, but guess what !?
There are not many, and not even that watchable.

What about provoking you guys to showoff your skills in drifting ?
@Hanney , you are not too old for this sh*t! Show us what you have got!


PS: Waiting reply, Honney!
PS2: Will upload the handling later today.
5
Snippet Showroom / [finally] Hydraulics' Alternative ! v1.1
« on September 25th, 11:20 PM »
CREDITS:


Hydraulics' Alternative
"  I'm presenting you the future  "

Synced, enabled by a command, actioned by keys
Best alternative to Voodoo's Hydraulics, inspired by SA*
Customizable anti-spam is implemented, to avoid chaos-makers (or not :P )
NUMPAD 8, 5, 4 and 6 are used for Front, Rear, Left and Right leans.
Shift is used to increase vehicle's height.*


(click to show/hide)
1.Registering locals, usually in the top of the script
Code: [Select]
local shift = BindKey( true, 0x10, 0, 0 );
local num8 = BindKey( true, 0x68, 0, 0 );
local num4 = BindKey( true, 0x64, 0, 0 );
local num6 = BindKey( true, 0x66, 0, 0 );
local num5 = BindKey( true, 0x65, 0, 0 );


/*     Hydraulics System done by Sebastian!     */
/*     Don't change the settings - too risky       */

local hyd_top = 2.4, // high level - actioned when pressing SHIFT - set 0 to remove the uppering (safer gameplay)
hyd_z = -0.1, // Centre of Mass Z
hyd_zl = 0.7, // Upper Limit variation -
hyd_lean = 1.4, // front lean
hyd_oplean = -1.4, // rear lean
hyd_side = 0.5, // right lean
hyd_opside = -0.5, // left lean
hyd_mark = -0.001, // trick
hyd_25 = array( 1000, 0 ), // had to do with the UpperLimit variation
hyd_ticks = array( 100, 0 ), // anti-spam of everyplayer
hyd_tickslimit = 600; // interval of time a player can bounce again (in miliseconds)

2. This goes under onPlayerJoin( player ) to reset player's ticks count
Code: [Select]
function onPlayerJoin( player )
{
hyd_ticks[ player.ID ] = 0;
}

3. This goes under onPlayerCommand( player, cmd, text )
Code: [Select]
switch( cmd )
{
case "hydraulics":
{
if( player.Vehicle ) return MessagePlayer( "[#00AAAA]Error - You must be driving a car!", player );
else if( player.VehicleSlot != 0 ) return MessagePlayer( "[#00AAAA]Error - Only the driver can action the hydraulics!", player );

local veh = player.Vehicle,
z = veh.GetHandlingData( 7 );

if( z != hyd_z )
{
veh.ResetHandlingData( 20 );
hyd_25[ veh.ID ] = hyd_zl;
veh.SetHandlingData( 20, hyd_25[ veh.ID ] );
veh.SetHandlingData( 7, hyd_z );

MessagePlayer( "[#00FFFF]Hydraulics were enabled !", player );
}
else
{
hyd_25[ veh.ID ] = 0;
veh.ResetHandlingData( 20 );
veh.ResetHandlingData( 7 );
MessagePlayer( "[#00AAAA]Hydraulics were disabled !", player );
}

veh.AddSpeed( Vector( 0, 0, 0 ) ); // used for the handling rule 24 to take effect
}
break;
}

4. Telling buttons what to do 8) via onKeyDown( player, key )
Code: [Select]
switch( key )
{
case shift:
case num8:
case num5:
case num4:
case num6:
{
if( !player.Vehicle ) return 0;
else if( player.VehicleSlot != 0 ) return 0;
else if( hyd_25[ player.Vehicle.ID ] == 0 ) return 0;
else if( ( GetTickCount() - hyd_ticks[ player.ID ] ) < hyd_tickslimit ) return 0;

local veh = player.Vehicle,
low = veh.GetHandlingData( 20 ),
val6 = veh.GetHandlingData( 6 ),
val5 = veh.GetHandlingData( 5 );

hyd_ticks[ player.ID ] = GetTickCount();
PlaySound( veh.World, 336, veh.Pos );

switch( key )
{
case shift:
{
if( low < hyd_top ) veh.SetHandlingData( 20, hyd_top );
else veh.SetHandlingData( 20, hyd_25[ veh.ID ] );

veh.AddSpeed( Vector( 0, 0, 0 ) );
}
break;

case num8: // front
case num5: // rear
{
if( low < hyd_top )
{
if( key == num8 ) return veh.SetHandlingData( 6, val6 + hyd_oplean );
else return veh.SetHandlingData( 6, val6 + hyd_lean );
}
else
{
veh.SetHandlingData( 20, hyd_25[ veh.ID ] + hyd_mark );
veh.AddSpeed( Vector( 0, 0, 0 ) );
if( key == num8 ) return veh.SetHandlingData( 6, val6 + hyd_lean );
else return veh.SetHandlingData( 6, val6 + hyd_oplean );
}
}
break;

case num4: // left
case num6: // right
{
if( low < hyd_top )
{
if( key == num4 ) return veh.SetHandlingData( 5, val5 + hyd_side );
else return veh.SetHandlingData( 5, val5 + hyd_opside );
}
else
{
veh.SetHandlingData( 20, hyd_25[ veh.ID ] + hyd_mark );
veh.AddSpeed( Vector( 0, 0, 0 ) );
if( key == num4 ) return veh.SetHandlingData( 5, val5 + hyd_opside );
else return veh.SetHandlingData( 5, val5 + hyd_side );
}
}
break;
}
}
break;
}

5. Last step takes us to onKeyUp( player, key )
Code: [Select]
switch( key )
{
case num8: // front
case num5: // rear
case num4: // left
  case num6: // right
{
if( !player.Vehicle ) return 0;
else if( player.VehicleSlot != 0 ) return 0;
else if( hyd_25[ player.Vehicle.ID ] == 0 ) return 0;

local veh = player.Vehicle,
low = veh.GetHandlingData( 20 ),
deflow = hyd_25[ veh.ID ];

if( low == ( deflow + hyd_mark ) )
{
veh.SetHandlingData( 20, hyd_top );
if( key == num8 || key == num5 ) return veh.ResetHandlingData( 6 );
else return veh.ResetHandlingData( 5 );
}
else
{
if( key == num8 || key == num5 ) return veh.ResetHandlingData( 6 );
else return veh.ResetHandlingData( 5 );
}
}
break;
}


PS: It could be a lot better/more real, but there is some bug happening due vc:mp or vc engine, so I couldn't use the method I've used in this video.
PS2: Not all vehicles will respond properly to this alternative, so be careful. Will try to find what's bothering other vehicles...
PS3: Because I was forced to use handling rule 24 instead of 25, vehicle can be more sensible when highered (after pressing shift). In order to remove the uppering, set hyd_top to 0 and that's it.
6
Videos & Screenshots / [Showoff] Proper Hydraulics ! (protoype)
« on September 22nd, 03:41 AM »
Missing Voodoo's hydraulics ? Here they are, synced !


https://youtu.be/1wTGMfaShvg

Will share the code with you within a week.
I just need to do some more testing and adjustments.

7
Videos & Screenshots / [Showoff] Proper NOS Effect.
« on June 29th, 05:05 PM »
8
Vehicle Showroom / [.xml] Tricks, Discoveries and Joy
« on June 9th, 04:52 PM »
I've made this post so I can share what I've found, with you.
Don't know how many of you know, but you can play with the engine more than R* did when about special features of vehicles.
Didn't test too much, but will update when I have news.
Also, if you have your own discoveries, feel free to share. Will put it in the list.

Flags calculator: https://vc-flags.netlify.com/
Original Author: @maxorator
Modified by: @MEGAMIND



1. Emergency Lights/Taxi Light can be used even if the vehicle is not properly categorized

Take the Flying Delly as example.
All you need to do, is adding this <specials></specials> category and play with the settings inside, like colors, position, if the lights should be turned on all the time or not, etc
(click to show/hide)
Code: [Select]
<specials>
<taxilight>
<alwayson>false</alwayson>
<colour>128,128,0</colour>

<position>
<x>0.0</x>
<y>0.0</y>
<z>0.95</z>
</position>
</taxilight>
</specials>
(click to show/hide)
Code: [Select]
<specials>
<emlights>
<alwayson>true</alwayson>
<colourone>50,255,50</colourone>
<colourtwo>50,50,255</colourtwo>

<posleft>
<x>-0.750687</x>
<y>-2.64971</y>
<z>-0.147924</z>
</posleft>

<posright>
<x>0.750687</x>
<y>-2.64971</y>
<z>-0.147924</z>
</posright>
</emlights>
</specials>
(click to show/hide)
Code: [Select]
<specials>
<emlightsingle>
<alwayson>false</alwayson>
<colour>70,70,255</colour>

<position>
<x>0.4</x>
<y>0.6</y>
<z>0.3</z>
</position>
</emlightsingle>
</specials>



2. Heli weapons will work only with heli flags, in .xml

Simple: Even with the weapons code inserted, weapons won't be active, if you use different flags than heli's.
So, in order to use Hunter's weapons, you gonna add heli's flags + specials + helidata.
Then, via script, you can play how much you want with the flags, because when you gonna reset the flags to heli's, weapons will be still working.

Heli's flags:
Code: [Select]
<flags>08028000</flags>
(click to show/hide)
Code: [Select]
<helidata>
<helitype>hunter</helitype>
<weapons>hunter</weapons>
<rotorradius>6.150000</rotorradius>
<rotordammult>0.500000</rotordammult>
</helidata>

<specials>
<heliweps>
<missilepos>
<x>2.5</x>
<y>1.0</y>
<z>-0.5</z>
</missilepos>

<machinegunpos>
<x>0.0</x>
<y>4.8</y>
<z>-1.3</z>
</machinegunpos>
</heliweps>
</specials>
(click to show/hide)
Code: [Select]
<helidata>
<helitype>water</helitype>
<weapons>sparrow</weapons>
<rotorradius>5.150000</rotorradius>
<rotordammult>0.800000</rotordammult>
</helidata>

<specials>
<heliweps>
<machinegunpos>
<x>0.0</x>
<y>4.8</y>
<z>-1.3</z>
</machinegunpos>
</heliweps>
</specials>



3. RC Vehicles and Boats are looping their animations!

So ? Well, try setting animation 0 of group 0, while driving one of these vehicles. Your player will start walking without stopping :P


https://www.youtube.com/watch?v=1mFEJ3OAjms

Maybe developers can follow this method of looping animations, for some proper function ?!



Notes:
  • you cannot mix lights styles (e.g.: taxi light with some emergency lights)
  • light style + heli weapons is posible
  • you can use special lights on helicopters too - don't know about the others, but it must work also. (boat tested, but no lights shown up)
  • even if you trick the flags, like I did with the Flying Delly, you cannot make weapons work when vehicle is a car.
    It must be helicopter.

(click to show/hide)
https://i.imgur.com/c7JhcDf.png - helicannon + lights



PS:
<author></author> setting acutally does something,
so when using downloaded vehicles in your server, don't forget to add the setting and the name.
9
Vehicle Showroom / [BTTF] Flying Delly - Featured Vehicle
« on June 4th, 12:08 PM »

Version: v1 Beta
Vehicle author: Spartan 112
I edited it to make it fit properly when car, but when helicopter mod too.

In order to make the switch between car and heli, you need to use the following code:
Code: [Select]
                if( veh.Model == 6440 )
                {
                    if( veh.GetHandlingData( 28 ) == -2 )
                    {
                        veh.SetHandlingData( 28, 10 );
                        return 0;
                    }
                    else if( veh.GetHandlingData( 28 ) == 10 )
                    {
                        veh.SetHandlingData( 28, -2 );
                        return 0;
                    }
                    else
                    {
                        veh.SetHandlingData( 28, 10 );
                    }
                }

Now, you can apply it by Binding a Button, to have the best experience posible. :P
Have fun!

Note: Stop the car before switching to the heli mod. Otherwise, it will continue to work as a car.
It's the game engine, nothing to do, except forcing the car's stop through script.


10
Clans and Families / [ ReadMe.txt ] YES, EVEN HERE !
« on February 23rd, 02:25 AM »
Seems like new guys need to know what's going on in this board, as I've seen numerous totally off-topic.
Besides off-topic, I've also seen players tryin' to "create" a clan where they were the only members.

As a first rule, I would like to say:
ANNOUNCING YOUR CLAN IS NOTHING LIKE CHECKING THE "I AGREE THE TERMS AND CONDITIONS" BOX
A clan must mean something, and not just a name !

So here comes the second rule:
CLAN MUST BE FAMILY
If you gonna read the definition of 'family', you will see that it is a group of people.
So YOU JUST CANNOT be the only one member !
Before announcing your clan, as a newbie lookin' for attention, go ahead and play - make friends, relationships.
Find guys who have the same purposes as you do, and make team with them !
Only then you can return here and announce it, if you and your mates dare to get more into the core !
As your name is, so the clan tag is. People won't forget your name nor your tag. So everything you do, will also affect the clan itself.

DECIDE WHAT IS THE PURPOSE OF YOUR CLAN
There are 3 types of clans: The Good, The Bad, and The Ugly
The Good - good intentions in making a good name, recruiting players, training them, treating them like family, being organized, ready to show what are made of, no matter what. Bright future ahead.
The Bad - a bunch of guys/kids thinking it will be fun to have their own clan; it's not a bad thing, as far as they don't announce it, because they are not taking it seriously.   It's all a play, so there is no name. No organization, no plains, no future.
The Ugly - hackers and cheaters, trying to ruin other players' gameplay. Bright BAN ahead.

SUPPORT
If you have decided yourself, and have the trusted people around, go ahead and announce it as a real leader !
Make visitors eyes-open when reading your announcement; tell them what it takes to be a member, and also what to expect from the clan. Convince them to join! It's so much about the first-view.
Then keep them up to date with everything, and so this topic, so everybody can see who has been promoted or depromoted, if it is still alive or not, etc.

I truly wish you the best !

There are some very serious clans in VC:MP, with long history. Just try to take a look at the board.
There are events taking place every year, where clans give their best to show what are they up to. Fighting, making every moment count.

Last rule: There is no rule saying that clans must be ONLY for deathmatching. You might not like fighting, but you like stunting, drifting. :P
11
Hey there !

I know there are servers which comunicate to Discord channels,
so I have to ask, as I'm gonna need it:
HOW TO ?

There is a Discord plugin for javascript plugin, made by @NewK , so everybody can make it happen.
Can somebody do one for Squirrel too ?
12
Tutorials / [howto] I/O functionality
« on July 29th, 2018, 11:35 AM »
// this was posted long time ago by SLC; had to be stickied even since
Quote from . on December 8th, 2015, 12:47 PM
The Squirrel standard library offers IO functionality. It's just a little more complicated for new users that don't know to process files in binary mode.

To open a file we use the file type constructor and pass the file name and desired flags/modes that we want to use when opening that file. Flags/modes are the similar to the C modes from fopen.

Code: [Select]
local myfile = file("text.txt","rb+");

In this case 'b' tells us that we open the file on binary mode and 'r+' allows us to both read and write/update to the file. The file must exist!

Then we use the readn(type); member function to read each byte from that file.

Code: [Select]
local my_str = "";

while (!myfile.eos())
{
    my_str += format(@"%c", myfile.readn('b'));
}

print(my_str);

We begin by creating a string variable `my_str` where we store the resulted string. Then we use the `eos()` (end of stream) member function to know when we reached the end of the file. If we reached the end of the file then `eos()` will return something different from null.

Then we read a single byte and since ASCII characters occupy a single byte that means we read a single character from the file. But a byte is nothing but a number. So we use the format function to convert that byte into a character which becomes a string. And we add the returned string which contains a single character to the actual string.

The list of values that you can read are as follows:
  • 'i' 32bits number returns an integer
  • 's' 16bits signed integer returns an integer
  • 'w' 16bits unsigned integer returns an integer
  • 'c' 8bits signed integer returns an integer
  • 'b' 8bits unsigned integer returns an integer
  • 'f' 32bits float returns an float
  • 'd' 64bits float returns an float

After that we print the retrieved text from the file. To write to a file we use the writen(type); member function which works just like the read function except it writes values.

Code: [Select]
local my_text = "Appended text goes here";

myfile.seek(0, 'e');

foreach (c in my_text)
{
    myfile.writen(c, 'b');
}

We begin by creating a dummy text string that will be appended to our current text. Then we move the cursor to the end of the file. We do that by seeking 0 bytes past the endpoint.

Then we use a foreach loop to process each character in our string. And since one ASCII character is one byte then we write them each as one byte.

The list of values that you can write are as follows:

  • 'l' processor dependent, 32bits on 32bits processors, 64bits on 64bits prcessors
  • returns an integer 'i'
  • 32bits number 's'
  • 16bits signed integer 'w'
  • 16bits unsigned integer 'c'
  • 8bits signed integer 'b'
  • 8bits unsigned integer 'f'
  • 32bits float 'd'
  • 64bits float

After we're done with the file we use the `close()` member function to close it and that's it.

Code: [Select]
myfile.close();



I suppose the whole code can be summarized into two simple read/write functions:
Code: [Select]
function ReadTextFromFile(path)
{
    local f = file(path,"rb"), s = "";

    while (!f.eos())
    {
        s += format(@"%c", f.readn('b'));
    }

    f.close();

    return s;
}

function WriteTextToFile(path, text)
{
    local f = file(path,"rb+"), s = "";

    f.seek(0, 'e');

    foreach (c in text)
    {
        f.writen(c, 'b');
    }

    f.close();
}

And used as:
Code: [Select]
print( ReadTextFromFile("test.txt") );

WriteTextToFile("test.txt", "Appended text goes here");

print( ReadTextFromFile("test.txt") );



I suppose the whole read function can also be optimized with a blob to avoid a ton of IO operations for a single byte.

Code: [Select]
function ReadTextFromFile(path)
{
    local f = file(path,"rb"), s = "", n = 0;
    f.seek(0, 'e');
    n = f.tell();
    if (n == 0)
        return s;
    f.seek(0, 'b');
    local b = f.readblob(n+1);
    f.close();
    for (local i = 0; i < n; ++i)
        s += format(@"%c", b.readn('b'));
    return s;
}
Also, SLC is sharing a function for reading between strings of a text:
Code: [Select]
// Assuming `text`, `begin_str` and `end_str` are all strings. no error checking

function GetTextBetween(text, begin_str, end_str, must_end = true) {
  // See where `begin_str` starts in the `text`
  local start_idx = text.find(begin_str, 0);
  // if `start_idx` is `null` then it wasn't found
  if (start_idx == null) {
    return null;
  }
  // Exclude `end_str` from the returned string
  start_idx += begin_str.len();
  // See where `end_str` starts in the `text`
  // Starting the search after where `begin_str` was located
  local end_idx = text.find(end_str, start_idx);
  // if `start_idx` is `null` then it wasn't found
  if (end_idx == null) {
    // If the end string must be present
    if (must_end) {
      return null; // Then return null
    // If the end string doesn't have to be present
    } else {
      // Return everything after `begin_str` (excluding `begin_str`)
      return text.slice(start_idx);
    }
  }
  // We have a beginning and an ending, so get that slice of text
  return text.slice(start_idx, end_idx);
}
13
Can somebody list all the risks of not using this function ? according to VC:MP.
I'm pretty sure this kind of topic will be helpful for much part of the comunity.
14
Client Scripting / [function] qGUI
« on June 10th, 2018, 01:01 AM »
I do need it, to avoid lots of useless code lines.
I'm sharing it, for people who might need it too.



We all know what's needed to create a basic .... label.
(click to show/hide)
        Account.Label4 = GUILabel( );
        Account.Label4.Pos = VectorScreen( 90, 280 );
        Account.Label4.FontSize = 12;
        Account.Label4.TextColour = Colour( 221, 221, 88 );
        Account.Label4.FontFlags = ( GUI_FFLAG_BOLD );
        Account.Label4.Text = "auto-login enabled";

6 damn code lines.
What if we gonna create a GUI Register system ? PLENTY of code, which can be shortened a lot.
So what do you say about 1 code line, instead of 6 ? :D
Much better!



I have created a function which does the job, with all the details you need.
For now, it includes code lines for Window, Label, Button, Checkbox, Editbox.
(which I believe are the most used ones so far)

Parameters
Window - qGUI( "window", pos, size, rgb, text, text_rgb, font_size, font_flags, remove_flags )
Label - qGUI( "label", pos, text_size, text_rgb, text, font_flags, font_name )
Button - qGUI( "button", pos, size, rgb, text, text_rgb, font_flags )
Checkbox - qGUI( "checkbox", pos, size, rgb )
Editbox - qGUI( "editbox", pos, size, rgb, text, text_rgb, flags )
(with green are optional arguments)

So here it is:
Code: [Select]
function qGUI( type, ... )
{
    if( vargv.len() >= 3 )
    {
        local   q = 0,
                pos = vargv[0],
                size = vargv[1],
                rgb = vargv[2];
               
        switch( type )
        {
            case "window":
            {
                q = GUIWindow();
               
                local   text = vargv[3].tostring(),
                        textrgb = vargv[4],
                        fontsize = vargv[5];
               
                q.Pos = pos;
                q.Size = size;
                q.Colour = Colour( rgb.R, rgb.G, rgb.B, 255 );
                if( rgb.A ) q.Alpha = rgb.A;
               
                q.Text = text;
                q.TextColour = Colour( textrgb.R, textrgb.G, textrgb.B );
                q.FontSize = fontsize;
               
                if( vargv.len() >= 7 ) q.FontFlags = ( vargv[6] );
                if( vargv.len() >= 8 ) q.RemoveFlags( vargv[7] );
            }
            break;
           
            case "label":
            {
                q = GUILabel();
               
                local   text = vargv[3].tostring();
                       
                q.Pos = pos;
                q.FontSize = size
                q.TextColour = Colour( rgb.R, rgb.G, rgb.B );
                q.Text = text;
               
                if( vargv.len() == 5 ) q.FontFlags = ( vargv[4] );
                if( vargv.len() == 6 ) q.FontName = vargv[5];
            }
            break;
           
            case "button":
            {
                q = GUIButton();
               
                local   text = vargv[3],
                        textrgb = vargv[4];
               
                q.Pos = pos;
                q.Size = size;
                q.Colour = Colour( rgb.R, rgb.G, rgb.B );
                q.Text = text;
                q.TextColour = Colour( textrgb.R, textrgb.G, textrgb.B );
               
                if( vargv.len() == 6 ) q.FontFlags = ( vargv[5] );
            }
            break;
           
            case "checkbox":
            {
                q = GUICheckbox();
               
                q.Pos = pos;
                q.Size = size;
                q.Colour = Colour( rgb.R, rgb.G, rgb.B );
            }
            break;
           
            case "editbox":
            {
                q = GUIEditbox();
               
                q.Pos = pos;
                q.Size = size;
                q.Colour = Colour( rgb.R, rgb.G, rgb.B );
               
                if( vargv.len() >= 4 ) q.Text = vargv[3];
                if( vargv.len() >= 5 ) q.TextColour = Colour( vargv[4].R, vargv[4].G, vargv[4].B );
                if( vargv.len() == 6 ) q.AddFlags( vargv[5] ); // like GUI_FLAG_EDITBOX_MASKINPUT
            }
            break;
        }
        if( q != 0 ) return q;
        else return srv_print( "GUI couldn't be created." );
    }
}



PS: I know I could set the pos and size and colour overall, by using just 3 lines.
But I preferred not to.
15
Scripting and Server Management / GUI CreateWindow() function
« on June 5th, 2018, 03:28 PM »
Hey there!

I'm looking forward for an overall function when creating GUI elements;
something like:
Code: [Select]
CreateWindow( size, colour, pos, text, textcolour, fontsize )

I tried my luck, but for some reason, it doesn't show up at all...
Code: [Select]
function qGUI( type, ... )
{
    switch( type.tostring() )
    {
        case "window":
        {
            local   q = GUIWindow(),
                    size = vargv[0],
                    colour = vargv[1],
                    pos = vargv[2],
                    text = vargv[3].tostring(),
                    textcolour = vargv[4],
                    fontsize = vargv[5];
                   
            q.Size = size;
            q.Colour = colour;
            q.Pos = pos;
            /* GENERAL */ q.FontFlags = ( GUI_FFLAG_BOLD );
            /* GENERAL */ q.RemoveFlags( GUI_FLAG_WINDOW_RESIZABLE | GUI_FLAG_WINDOW_CLOSEBTN );
            q.Text = text;
            q.TextColour = textcolour;
            q.FontSize = fontsize;
       
        break;
        }
}

If I do it in the classic way (one-by-one function for every setting) it will work.
What's going on ? How can I make it work ?