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

Topics - Milos

#1
Snippet Showroom / Top Killers System
Mar 11, 2019, 04:20 PM

And I created a Top Killer system without using database every time it is called:

Create a table:
Accounts <- {}; /* Table where accounts will be */
Functions:
/* Let's say we are loading the accounts from the database */
function loadAccounts() {
    //9 "accounts"
    Accounts.rawset(1, {Name = "Player1", Kills = rand() % 1000});
    Accounts.rawset(2, {Name = "Player2", Kills = rand() % 1000});
    Accounts.rawset(3, {Name = "Player3", Kills = rand() % 1000});
    Accounts.rawset(4, {Name = "Player4", Kills = rand() % 1000});
    Accounts.rawset(5, {Name = "Player5", Kills = rand() % 1000});
    Accounts.rawset(6, {Name = "Player6", Kills = rand() % 1000});
    Accounts.rawset(7, {Name = "Player7", Kills = rand() % 1000});
    Accounts.rawset(8, {Name = "Player8", Kills = rand() % 1000});
    Accounts.rawset(9, {Name = "Player9", Kills = rand() % 1000});
/* NOTE: You will have to adapt this function to load all the accounts of your database. */
}

function topKills() {
    /*Here, we will temporarily clone the original table, because we will
      have to delete some data (and we do not want this to happen in the main table)*/
    local backup_Accounts = clone Accounts;
 
    local limit = 5, tmp = "";
    while (limit) {
        local topScore = 0, index = 0;
        foreach (i, v in backup_Accounts)
        {
            if (backup_Accounts[i]["Kills"] > topScore) {
                topScore = backup_Accounts[i]["Kills"];
                index = i;
            }
        }
        if (index) tmp = tmp + backup_Accounts[index]["Name"] + " - " + backup_Accounts[index]["Kills"] + ", ";
        backup_Accounts.rawdelete(index);
        limit --;
    }
    return tmp != "" ? tmp.slice(0, tmp.len() - 2) : "No top killers";
}
 
function getAccountID(str) {
    foreach (i, v in Accounts) {
        if (Accounts[i]["Name"].tolower() == str.tolower()) {
            return i;
            break;
        }
    }
    return 0;
}

Server Events:
function onScriptLoad() {
    loadAccounts();
    print(topKills());
}
 
function onPlayerKill(killer, player, reason, bodypart) {
    /* Do not forget to update the amount of kills when the player scores */
    local i = getAccountID(killer.Name);
    if (i) Accounts[i]["Kills"] ++;
}

Result:


My server:


* I do not know why it always starts with the same values, even using the rand(), but you can change each kill in the loadAccounts function to confirm the script's operation (Someone explains to me)

#2
I think that would be very interesting.
Can anyone tell me if this is included in the TODO list?

#3
Off-Topic General / Do you have GTA IV EFLC?
Jun 15, 2018, 04:05 AM
Do you have GTA IV EFLC?
Have you seen the IVMP community?
Not the old one that died, but this one now that came back with the T4 version.
#4
Any way to do this?
#5
Console:


Files:


Visual C++ versions:


Obs:
1. Using x32 version, everything opens normally, but only with the presence of the dll's: libeay32(0.9.8.12) and ssleay32(0.9.8.10) for the IRC plugin;
2. Without these dlls in the x64 version, occurs error with code 126. In this case I'm using them, and it gives me the code 193.

What's missing to load them in x64 version?
#6
General Discussion / Fonts for client-side
Jun 17, 2017, 07:30 PM
What are all the fonts I can use?
some that I put, simply do not appear, except for Verdana, Tahoma, Consolas. What are all supported by client-side?
#7
Support / Steam Version?
Jun 10, 2017, 04:22 PM
How to fix this?
#8
General Discussion / About GlobalVariable
Apr 26, 2016, 07:27 PM
I created a function to add all users registered on my server in a global variable. But my question is: Is there a data limit for it?
If I have 5000 accounts, this variable will hold all?

Users <- [];

function LoadAccounts()
{
local q = QuerySQL( db, "SELECT * FROM Accounts" );
while ( GetSQLColumnData( q, 0 ) )
{
Users.push( GetSQLColumnData( q, 0 ) );
GetSQLNextRow( q );
}
FreeSQLQuery( q );
}
#9
Which is better?
Ternary have any advantage? It's faster than if/else?

if ( player.FPS.tointeger() >= 60 ) PrivMessage( player, "Nice FPS! :D" );
else PrivMessage( player, "Good FPS! :)" );
//-------------------------------------- or --------------------------------------
PrivMessage( player, format( "%s", player.FPS.tointeger() >= 60 ? "Nice FPS! :D" : "Good FPS! :)" ) );
#10
General Discussion / Skin ID wrong
Apr 24, 2016, 04:07 PM
When the skins problem will be solved?
I always see updates, but things like that are never fixed ::)

Theory:
  Hilary(110)                           Love Fist #2(111)


VCMP:
Hilary(110)   


Love Fist #2(111)


Wiki can not be wrong, because the skins are with different names. the IDs are the same too

http://forum.vc-mp.org/?topic=2543.0
#11
Support / [Solved]Auto-kick for wep
Apr 24, 2016, 04:20 AM
When I'm using weapon mod and change sometimes, the server kicks me. How to disable this? Why does it happen?

#12
I suggest adding this function. It would be essential for RPG servers.
Add these marks where someone dies.

#13
Support / GetSkinName
Apr 01, 2016, 09:58 PM
Is there any way to get the name of a skin mod using GetSkinName function?
e.g. I use some skins mods as:


But when I use GetSkinName in some skin mod returns me a null string: (null : 0x(nil))
But along with the skins have the name in XML:

<?xml version="1.0" encoding="ASCII"?>
<skin>
 <basic>
  <name>Amanda</name>
  <animgroup>busywoman</animgroup>
  <animfile>null</animfile>
 </basic>
</skin>
My solution was to create my own function. But there how to use XML to get this information?
#14
Is it a bug or am I using it wrong?

function onScriptLoad()
{
SetDrivebyEnabled( false );
print( "What is the answer? R: " + GetDrivebyEnabled() );
}



I'm trying to create an admin command and this is reversed.