Menu

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.

Show posts Menu

Messages - umar4911

#31
Credits:

VC:MP Icons Font
This font allows to use icons in your GUI Labels. Here is the chart:



Originally it has more than 90 glyphs, try going through character map to view them all (some of them might be repeating).

It has all properties of a normal GUILabel. You can use TextColour, align, padding, flags, or whatever you want.

Download:
https://www.mediafire.com/file/x6068hfb5l7bhs4/FAEditUmar_unp.7z/file

Installation:
Paste the 7z file in store/fonts


Usage:
- Use FontName of a Label as "FAEditUmar"

Note: The size of some of the icons might be varying.
#32
Update: Added enumerations as the start and added in the whole script
#33
Update: Added enumerations
#34
Quote from: Xmair on May 25, 2020, 11:30 AMIt's a lot better to check for the health on the client side each frame than it is to send streams each time health changes from the server. For the streams, you should consider storing the stream identifiers in enumerations. Other than that, good one.
since one of the main objective of the tutorial was to send data from server to client. That's the reason, I'm sending data each time health changes. I wasn't getting any example in my mind so what I got, I made. I was even thinking to send data onPlayerJoin :P (but didn't due to script load delay)

For streams identification, I myself prefer enum. It was just a basic tutorial that's the reason I'm didn't make it. Thanks for your opinion btw.
#35
Ping is not only dependent on your internet connection. I had at first 4mbps connection, I used to get 160 ping. Now I have 30mbps connection but still, the ping is 150-160. The ping also depends on the traceroute.

Your ISP
If your ISP is providing you a bad traceroute to the specific location, you'll be getting high ping. In bad, it can be divided into two parts
1. The traceroute is very long (it means you are very far from the host location)
2. The traceroute is poor, the responding time of the various IPs is very high (obviously done by ISP to reduce their expenses)

Solutions:
- Find a better ISP who provides better traceroute if your ISP can't change your traceroute (try contacting them)
- Travel around the world close to the Host location so the traceroute is shorter and you can get better ping
#36
There are already a lot scripts posted in the subboards:
https://forum.vc-mp.org/?board=11.0
https://forum.vc-mp.org/?board=12.0

You can also go through the alternate wiki for more help
http://wiki.thijn.ovh/

Try reading the scripts and understand how it works + you got wiki to support you
#37
Support / Re: Help me fix problem!
May 25, 2020, 08:05 AM
What is the error? Like the index NPC_ARRAY doesn't exist, etc.
#38
I wrote this guide for a friend who wanted to know how to send data from server to client and how to use DecUI. I thought why not post here too.

The function is taken from here https://forum.vc-mp.org/?topic=4484 Credits: Seby
DecUI is taken from here https://forum.vc-mp.org/?topic=6775 Credits: NewK


P.S: Sorry in advance if it's a little messed up.

Comments are added in each code for more explanation.





okay first example. We are sending kills from the server which should show to the player using a label


In order to record the identifier bytes, we can use enumerations (enum as short) like

[noae][noae][noae][noae]enum ByteInfo {
Kills = 0x02
}
[/noae][/noae][/noae][/noae]

Let's set that as soon as player spawns, it is shown.

[noae][noae][noae][noae][noae]

enum ByteInfo {
Kills = 0x02
};


function onPlayerSpawn(player)
{
// The ByteInfo.Kills will record it's identifier
SendDataToClient(player, ByteInfo.Kills, status[player.ID].kills, status[player.ID].Deaths)

// We send 3 values to the client, in the order, byte, int, int
}

// here is the special func
function SendDataToClient( player, ... )
{
if( vargv[0] )
{
local   byte = vargv[0], len = vargv.len();
Stream.StartWrite();
Stream.WriteByte( byte );
if( 1 < len )
{
for( local i = 1; i < len; i++ )
{
switch( typeof( vargv[i] ) )
{
case "integer": Stream.WriteInt( vargv[i] ); break;
case "string": Stream.WriteString( vargv[i] ); break;
case "float": Stream.WriteFloat( vargv[i] ); break;
}
}
}
if( player == null ) Stream.SendStream( null );
else if( typeof( player ) == "instance" ) Stream.SendStream( player );
else return;
}
}
[/noae][/noae][/noae][/noae][/noae]



Now we have sent data from the server. Lets get those values in client side
[noae][noae][noae][noae][noae]
enum ByteInfo {
Kills = 0x02
};


function Server::ServerData(Data)
{
// the first parameter we sent for all the data packets will be a byte so lets get it
local byte = Data.ReadByte();
// the local will store it's value

//since we used ByteInfo.Kills for the kills label
switch (byte)
{
case ByteInfo.Kills:
// the next values we sent where kills and deaths in the order and both were int vals
local kills = Data.ReadInt(),
deaths = Data.ReadInt();
// values stored

// I'll use a func to make the labels
CreateKillsGUI(kills, deaths);
break;
default: break;
}
}

function CreateKillsGUI(kills, deaths) {
// you know the drill how to create GUILabels

// In order to help you, I'll use DecUI to Create a Label
local LabelKills = UI.Label({
    id = "KillsLabel" 
    Text = "Kills: " + kills
FontSize = 16
TextColour = Colour(255, 255, 255)
// It helps you do some cool alignments
align = "hud_bottom"
FontFlags = (GUI_FFLAG_BOLD)

// I want the label to move a little more down
move = {down = "10%"}
});


local LabelDeaths = UI.Label({
    id = "LabelDeaths" 
    Text = "Deaths: " + deaths
FontSize = 16
TextColour = Colour(255, 255, 255)
align = "hud_bottom"
FontFlags = (GUI_FFLAG_BOLD)

// deaths should be a bit more down
move = {down = "13%"}
});
}
[/noae][/noae][/noae][/noae][/noae]

Since we created the labels in DecUI, we will be needing the update the labels too.

Let's make like, the player uses the same byte to send the data and the same function to update the labels. We will edit our function

[noae][noae][noae][noae][noae]function CreateKillsGUI(kills, deaths) {
    // We used ID `KillsLabel` to create Label for kills

    if(UI.Label("KillsLabel") != null)
    {
        // if the value is not null, means a label with that ID exists
        UI.Label("KillsLabel").Text = "Kills: " + kills
    }
    else
    {
        // if the condition is null, means the label doesn't exist. Lets create it
        local LabelKills = UI.Label({
            id = "KillsLabel" 
            Text = "Kills: " + kills
            FontSize = 16
            TextColour = Colour(255, 255, 255)
            // It helps you do some cool alignments
            align = "hud_bottom"
            FontFlags = (GUI_FFLAG_BOLD)

            // I want the label to move a little more down
            move = {down = "10%"}
        });
    }
    // similar for the deaths

    if(UI.Label("LabelDeaths") != null)
    {
        UI.Label("LabelDeaths").Text = "Deaths: " + deaths
    }
    else
    {
        local LabelDeaths = UI.Label({
            id = "LabelDeaths" 
            Text = "Deaths: " + deaths
            FontSize = 16
            TextColour = Colour(255, 255, 255)
            align = "hud_bottom"
            FontFlags = (GUI_FFLAG_BOLD)

            // deaths should be a bit more down
            move = {down = "13%"}
        });
    }
}
[/noae][/noae][/noae][/noae][/noae]
Okay let's do some more cool things with DecUI. Let's create a progress bar for health instead of the text


We will be using event onPlayerHeathChange. Also we need to add another identifier in the enum.
Server Side
[noae][noae][noae][noae][noae]enum ByteInfo {
Kills = 0x02
HpBar = 0x03
};

function onPlayerHeathChange(player, oldHp, newHp)
{
//since we need to send the new health only and Health is a float value, we'll convert to integer
SendDataToClient(player, ByteInfo.HpBar, newHp);
}
[/noae][/noae][/noae][/noae][/noae]


Client-Side has a function `Script::ScriptLoad()` which runs when all files are downloaded and loaded in the server. Acts like onPlayerJoin

Client Side
[noae][noae][noae][noae][noae]// lets get the func scriptload
enum ByteInfo {
Kills = 0x02
HpBar = 0x03
};

function Script::ScriptLoad() {

    // first of all, we need to remove the player's health from hud
    Hud.RemoveFlags( HUD_FLAG_HEALTH );

    SetHealthBar(); // the function used to create the health bar
}

// to change the values of the progressbar when player's health change
function Server::ServerData(Data)
{
// the first parameter we sent for all the data packets will be a byte so lets get it
local byte = Data.ReadByte();
// the local will store it's value

switch (byte)
{
case ByteInfo.Kills: // kills label
// the next values we sent where kills and deaths in the order and both were int vals
local kills = Data.ReadInt(),
deaths = Data.ReadInt();
// values stored

// I'll use a func to make the labels
CreateKillsGUI(kills, deaths);
break;

        case ByteInfo.HpBar: //GUI Health bar
            // we sent player's health which is in an int value. Lets store that in a variable
            local health = Data.ReadInt();

            // lets create using a func again
            SetHealthBar(health);
        break;
default: break;
}
}

//now the function itself
function SetHealthBar(health = 100) {

    // we will use canvas and add progress bar as its child so we can easily position the label

    // condition to check if the health was already present
    if(UI.Canvas("HealthCanvas") == null)
    {
        local hpcan = UI.Canvas({
            id = "HealthCanvas" 
            // another cool func in DecUI
            RelativeSize = ["7%", "3.5%"] // parameters are width and height, using percent means the part of the screen size of the player
           
            // we want it at the position of old health bar and hud_left doesn't exist :c
            align = "hud_right"
            move = {left = "19.5%", down = "8.5%"}               
           
            // lets add a progressbar but as a child of the canvas
            children = [
                // progressbar
                UI.ProgressBar({
                    id = "HealthBar"
                    RelativeSize = ["100%", "100%"] // it will inherit the size of the canvas since canvas is it's parent


                    // some basic things
                    MaxValue = 100
                    Thickness = 2
                    StartColour = Colour(255, 77, 77)
                    EndColour = Colour(150, 40, 40)
                    selectedColour = Colour(255, 100, 100)
                    Value = health
                })
                // now lets add a label
                UI.Label({
                    id = "HealthLabel" 
                    Text = health + "%"
                    FontSize = 12
                    TextColour = Colour(255, 255, 255)
                    align = "center" // it will align itself according to the canvas since canvas is the parent. center means to the center of the canvas
                })
            ]
        });
    }
    else
    {
        // when we receive the data from the server when player health is changed


        //if the canvas is already present, then obv children will also be. lets change their values
        UI.ProgressBar("HealthBar").Value = health;
        UI.Label("HealthLabel").Text = health + "%";   
    }
}
[/noae][/noae][/noae][/noae][/noae]
#39
Happy Birthday @habi
#40
Quote from: 3416 on May 15, 2020, 09:26 AM
Quote from: umar4911 on May 15, 2020, 08:24 AMExplain a bit more. You create a pickup using the command. If no one enters the pickup within 5 seconds, it is auto removed. Right na?
Yes!
If you are doing with only 1 pickup:
Store the pickup id in an array/table with a false value when creating the pickup. Create a Timer to check the pickup
PickupEntered <- [];
 function onPlayerCommand ( player, cmd, text )
if ( cmd == "pick" )
{
local pic = CreatePickup(368, player.World, 50, Vector(player.Pos.x, player.Pos.y, player.Pos.z), 255, true);
PickupEntered <- [pic.ID, false];
NewTimer("checkpickup", 5000, 1);
}
On the event OnPickupPickedUp, change the value of false to true;
function onPickupPickedUp( player, pickup )
{
if(pickup.ID == PickupEntered[0])
{
PickupEntered[1] <- true;
}
}

The function checkpickup
function checkpickup()
{
 if(PickupEntered[1] == false)
{
local pickup = FindPickup(PickupEntered[0]);
if(pickup) pickup.Remove();
}
}
#41
Quote from: Gulk2 on May 13, 2020, 10:17 PMTry to use the forum search function anymore,

function onPlayerRequestClass( player, classID, team, skin )
{
switch( skin )
    {
    case 1:
    {
SetCinematicBorder( player, true );
SetGreenScanLines( player, true );
SetSpawnPlayerPos( -971.0, 280.0, -100.0 );
player.SetCameraPos(Vector(-971.0, 280.0, 40.0),Vector(-1067.0, 320.0, 10.0));
player.PlaySound(361);
player.PlaySound(363);
Announce( "ROBBER", player, 0 );
    }
    break;
    case 2:
    {
SetCinematicBorder( player, true );
SetGreenScanLines( player, true );
SetSpawnPlayerPos( -1421.0, -760.0, -100.0 );
player.SetCameraPos(Vector(-1421.0, -760.0, 40.0),Vector(-1435.0, -833.0, 14.0));
player.PlaySound(361);
player.PlaySound(363);
 Announce( "MEXICAN", player, 0 );
    }
    break;
    case 3:
    {
SetCinematicBorder( player, true );
SetGreenScanLines( player, true );
SetSpawnPlayerPos( -690.0, -1360.0, -100.0 );
player.SetCameraPos(Vector(-690.0, -1360.0, 11.0),Vector(-680.0, -1250.0, 35.0));
player.PlaySound(361);
player.PlaySound(363);
Announce( "SAILOR", player, 0 );
    }
    break;
    case 4:
    {
SetCinematicBorder( player, true );
SetGreenScanLines( player, true );
SetSpawnPlayerPos( 409.0, 656.0, -100.0 );
player.SetCameraPos(Vector(409.0, 656.0, 40.0),Vector(428.0, 608.0, 17.0));
player.PlaySound(361);
player.PlaySound(363);
Announce( "VC CRUSADER", player, 0 );
    }
    break;
    case 5:
    {
SetCinematicBorder( player, true );
SetGreenScanLines( player, true );
SetSpawnPlayerPos( 34.5, -1178.5, -100.0 );
player.SetCameraPos(Vector(34.5, -1178.5, 20.0),Vector(7.0, -1211.0, 9.4));
player.PlaySound(361);
player.PlaySound(363);
Announce( "SECRET SERVICE", player, 0 );
    }
 break;
    case 6:
    {
SetCinematicBorder( player, true );
SetGreenScanLines( player, true );
SetSpawnPlayerPos( 474.4, -1717.5, 56.2 );
player.SetCameraPos(Vector(474.4, -1717.5, 70.0),Vector(173.0, -1454.0, 26.0));
player.PlaySound(361);
player.PlaySound(363);
Announce( "SPECTATOR", player, 0 );
    }
 break;
    case 7:
    {
SetCinematicBorder( player, true );
SetGreenScanLines( player, true );
SetSpawnPlayerPos( -836.0, -638.0, -100.0 );
player.SetCameraPos(Vector(-836.0, -638.0, 15.0),Vector(-866.0, -679.0, 1.0));
player.PlaySound(361);
player.PlaySound(363);
Announce( "COP", player, 0 );
    }
 }
}
You are repeating the 4 lines again and again.
SetCinematicBorder( player, true );
SetGreenScanLines( player, true );
SetSpawnPlayerPos( -971.0, 280.0, -100.0 );

player.PlaySound(361);
player.PlaySound(363);
Instead of repeating, why not using it once?
#42
Explain a bit more. You create a pickup using the command. If no one enters the pickup within 5 seconds, it is auto removed. Right na?
#43
Support / Re: Weird Ping Problem
May 10, 2020, 11:48 AM
Quote from: HaseeB^ on May 09, 2020, 12:28 PMHi! I recently changed my Windows 7 to 10, now I am facing a weird issue that my PIng remains high in every server I join, like between 300 to 1000. I use 4g Mobile Internet and the speed is fine when browsing or downloading something but still, I get this high ping. This issue has happened to me back in 2017, one of my friends Sindhist helped me with it but now I have forgotten the solution.
Extra: I cleared Crash logs but it didn't work.
try ping www.google.com -t in command prompt and see what is shows.


Quick question, is your ping stable at 300? Or your ping keeps on spiking? Like you jave 150, the second 1K, 2 sec later 500, then 150 and something like this?
#44
Script Showroom / Re: DI System
May 10, 2020, 11:45 AM
Quote from: =RK=MarineForce on May 10, 2020, 04:46 AMDI TIMING SYSTEM

so you guys thinking how can we make timer?

its the best ez waya to make timer:

ITS HELP YOU ALOT IN A GOOD GAMEMODE!

example

add this onscriptload.

g_timer <- 0;
NewTimer( "g_timer", 1000, 0);
function rounds()
{

if ( g_timer == 180 )
{
Message(" Round Has Been Ended Due To Time Over");
g_timer = 0;                                             
}
Announce( "~y~ TIME : " + g_timer + " ", player , 1 )
g_timer++;
}

}

how to minus time:

g_timer --;
how to plus time:

g_timer++;
how to reset time:

[code]g_timer = 0;
how to set time:

Command:
if(cmd=="settime")
{
        if ( text && IsNum( text ) )
        {               
g_timer = text.tointeger();
MessagePlayer( "[#ffffff][ADMIN][#00ff00] Set the Time: [#ffbb00]"+g_timer+"",player);
}
}

You can add many times for example
etc <- 0;
g_xx <- 0;
g_pp <- 0;

IF YOU ADDED IT IN ONSCRIPTLOAD BUT IF U ADD (PLAYER) IT WILL WONT WORK! THATS PROB add it onroundstart etc. you can STOP THE ANNOUNCE BY g_timer.Stop()
tbh cancer. You're having timer every second. I prefer you creating a countdown in client side. This will reduce the lag a lot. Using functions, you can even change the time, end and do whatever you want without adding lag to the server.
#45
https://forum.vc-mp.org/?topic=898.0

QuoteVerify that the script is working properly.
Take your script, extract it, and start fresh with the latest Squirrel server available. If you are using a database, erase it and start from scratch. Make absolutely sure that all functions and commands are working as they should.

If your script uses a database, make sure that you either add a bare-bones Database file with all unnecessary entries removed, or that you include a file with the CREATE TABLE/INSERT statements that need to be run.

The title......