This topic has been moved to Script and Content Requests.
https://forum.vc-mp.org/index.php?topic=9421.0
https://forum.vc-mp.org/index.php?topic=9421.0
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.
Show posts Menufunction test() {
arr <- array(100);
for (local i = 0; i < arr.len(); i++) {
arr[i] = GUILabel( VectorScreen( 300, 300 ), Colour( 255,255,255 ), "FontSize changing + ESC to MENU speed!" );
arr[i].FontFlags = GUI_FFLAG_OUTLINE;
arr[i].FontSize = 11;
Console.Print( "created label no " + i );
}
}
test();
function Server::ServerData( stream )
if it's sent by server, and function onClientScriptData( player )
if sent by clientStream.StartWrite();
Stream.WriteInt(0); // key / id
Stream.WriteInt(51); // needed value
Stream.SendStream(player);
and here is a stream e.g. from CLIENT -> SERVER local Data = Stream();
Data.WriteInt(0); // key / id
Data.WriteString("Explosion"); // needed value
Server.SendData(Data);
those keys I've been put into examples must be considered as casesfunction onClientScriptData( player )
{
local id = Stream.ReadInt();
switch( id ) {
case 0: {
// death message related
local msg = Stream.ReadString();
MessagePlayer( "Client data received - death message: " + msg, player );
} break;
case 1: {
// position related
} break;
default: {
// even was called, but with an ID not existing in this switch
} break;
}
}
function Server::ServerData( stream )
{
local id = stream.ReadInt();
switch( id ) {
case 0: {
// death message related
local reasonID = stream.ReadInt();
Console.Print( "Death Reason ID received from Server: " + reasonID );
} break;
case 1: {
// position related
} break;
default: {
// even was called, but with an ID not existing in this switch
} break;
}
}
Stream()
function, like you have seen in the examples aboveServer::ServerData( stream )
, then you can see that the parameter is named stream with small s.Quote from: wikiGUILabel
1. Constructor GUILabel()
2. Constructor GUILabel(position, colour)
Parameter types: VectorScreen, Colour
3. Constructor GUILabel(position, colour, text)
Parameter types: VectorScreen, Colour, string
4. Constructor GUILabel(position, colour, text, flags)
Parameter types: VectorScreen, Colour, string, int
label.Size = VectorScreen(0,0);
label.TextPaddingTop = 0; // or Right, or Left, or Bottom, as any of them seem to do the thing
[spoiler=all TextPadding functions]if( cmd == "s" || cmd == "save" )
{
local veh = player.Vehicle;
local newline;
if( !veh ) {
// the below script will check all player's weapons and save the first 3 the script founds
local wep = array(3);
wep[0] = { ID = 0, Ammo = 0 };
wep[1] = { ID = 0, Ammo = 0 };
wep[2] = { ID = 0, Ammo = 0 };
local weps = 0;
for( local i = 0; i < 9; i++ ) {
if( player.GetWeaponAtSlot(i) != 0 && weps < 3 ) {
wep[weps] = {
ID = i,
Ammo = player.GetAmmoAtSlot(i)
};
weps++;
if( weps == 3 ) break;
}
}
// format is AddClass( class, color, skin, position, angle, weapon1, ammo1 ,weapon2, ammo2, weapon3, ammo3 );
newline = "AddClass( " + player.Class + ", RGB(" + player.Colour.r + ", " + player.Colour.g + ", " + player.Colour.b + "), "
+ player.Skin + ", Vector" + player.Pos + ", " + player.Angle + ", "
+ wep[0].ID + ", " + wep[0].Ammo + ", " + wep[1].ID + ", " + wep[1].Ammo + ", " + wep[2].ID + ", " + wep[2].Ammo + " ); \n";
}
else {
// format is CreateVehicle( model, world, pos, angle, col1, col2 )
newline = "CreateVehicle( " + veh.Model + ", " + veh.World + ", Vector" + veh.Pos + ", " + veh.Rotation.z + ", " + veh.Colour1 + ", " + veh.Colour2 + " ); \n";
}
local f = file("savedpositions.txt","a+");
foreach (c in newline)
f.writen(c, 'b');
f.close();
}
<?xml version="1.0" encoding="ASCII"?>
<skin>
<basic>
<name></name>
<animgroup></animgroup>
<animfile></animfile> <!--not really used -->
<overrideanims></overrideanims>
</basic>
</skin>
name = simply your skin name; in our case: Fat TommyQuote from: StormeusAdded support for loading precompiled client-side scripts (i.e. .cnut files). These must be compiled on a 32-bit Squirrel instance.
AN ERROR HAS OCCURRED [the index '<constant name>' does not exist]
const wayLoadScripts = 0;
function include2( path )
{
if( wayLoadScripts == 0 ) return 0;
else include( path );
}
[/spoiler]MSG: <filename> line = (1) column = (1) : error expression expected
Warning in CScriptFunctions::DoFile: (script/<filename>.cnut) expression expected
Warning in CScriptFunctions::DoFile: Attempting bytecode read of file.
Don't worry, it is not a problem. The client just tries to read the file as uncompiled first.function RegisterHandling( model, path )
{
print( "Registering handling " + model + " from " + path );
local file = ReadTextFromFile( path );
local bias = GetBetweenEvery( file, "<bias>", "</bias>" ),
x = GetBetweenEvery( file, "<x>", "</x>" ),
y = GetBetweenEvery( file, "<y>", "</y>" ),
z = GetBetweenEvery( file, "<z>", "</z>" ),
drivetype = GetBetween( file, "<drivetype>", "</drivetype>" ),
enginetype = GetBetween( file, "<enginetype>", "</enginetype>" );
if( drivetype == "4" ) drivetype = 52;
else if( drivetype == "F" ) drivetype = 70;
else if( drivetype == "R" ) drivetype = 82;
if( enginetype == "P" ) enginetype = 80;
else if( enginetype == "D" ) enginetype = 68;
else if( enginetype == "E" ) enginetype = 69;
SetHandlingRule( model, 1, GetBetween( file, "<mass>", "</mass>" ).tofloat() );
if( x.len() == 2 )
{
// dimensions
SetHandlingRule( model, 2, x[0].tofloat() );
SetHandlingRule( model, 3, y[0].tofloat() );
SetHandlingRule( model, 4, z[0].tofloat() );
// centre of mass
SetHandlingRule( model, 5, x[1].tofloat() );
SetHandlingRule( model, 6, y[1].tofloat() );
SetHandlingRule( model, 7, z[1].tofloat() );
}
else
{
SetHandlingRule( model, 5, x[0].tofloat() );
SetHandlingRule( model, 6, y[0].tofloat() );
SetHandlingRule( model, 7, z[0].tofloat() );
}
// SetHandlingRule( model, 8, GetBetween( file, "<percentsubmerged>", "</percentsubmerged>" ).tofloat() ); // at the moment, it is buggy to set this value. (vehicles will teleport when touching water)
SetHandlingRule( model, 9, GetBetween( file, "<multiplier>", "</multiplier>" ).tofloat() );
SetHandlingRule( model, 10, GetBetween( file, "<loss>", "</loss>" ).tofloat() );
SetHandlingRule( model, 11, bias[0].tofloat() );
SetHandlingRule( model, 12, GetBetween( file, "<numofgears>", "</numofgears>" ).tofloat() );
SetHandlingRule( model, 13, GetBetween( file, "<maxspeed>", "</maxspeed>" ).tofloat() );
SetHandlingRule( model, 14, GetBetween( file, "<acceleration>", "</acceleration>" ).tofloat() );
SetHandlingRule( model, 15, drivetype.tofloat() );
SetHandlingRule( model, 16, enginetype.tofloat() );
SetHandlingRule( model, 17, GetBetween( file, "<deceleration>", "</deceleration>" ).tofloat() );
SetHandlingRule( model, 18, bias[1].tofloat() );
SetHandlingRule( model, 19, GetBetween( file, "<steeringlock>", "</steeringlock>" ).tofloat() ); // "<abs>", "</abs>" ).tofloat() );
SetHandlingRule( model, 20, GetBetween( file, "<forcelevel>", "</forcelevel>" ).tofloat() );
SetHandlingRule( model, 21, GetBetween( file, "<dampening>", "</dampening>" ).tofloat() );
SetHandlingRule( model, 22, GetBetween( file, "<seatoffset>", "</seatoffset>" ).tofloat() );
SetHandlingRule( model, 23, GetBetween( file, "<damagemultiplier>", "</damagemultiplier>" ).tofloat() );
SetHandlingRule( model, 24, GetBetween( file, "<upperlimit>", "</upperlimit>" ).tofloat() );
SetHandlingRule( model, 25, GetBetween( file, "<lowerlimit>", "</lowerlimit>" ).tofloat() );
SetHandlingRule( model, 26, bias[2].tofloat() );
SetHandlingRule( model, 27, GetBetween( file, "<antidive>", "</antidive>" ).tofloat() );
SetHandlingRule( model, 28, ("0x" + GetBetween( file, "<flags>", "</flags>" )).tofloat() );
SetHandlingRule( model, 29, GetBetween( file, "<front>", "</front>" ).tofloat() );
SetHandlingRule( model, 30, GetBetween( file, "<rear>", "</rear>" ).tofloat() );
SetHandlingRule( model, 31, 0.0 );
SetHandlingRule( model, 32, 0.0 );
SetHandlingRule( model, 33, 0.0 );
print( ". Loaded handling for " + model );
}
[/noae][/noae]