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 - Nihongo^

#61
As you guys know Vcmp has now more hackers
Many of these hackers are using VPNs to bypass their bans and return to the server. Additionally, banning their UIDS are useless too

I've heard that many other servers are successfully utilizing VPN detection to address this problem. I've tried searching for information on VPN detection in this forum, but it appears that no one has shared any relevant solutions yet.

Currently, my server's script is based on the Squirrel language, and I'm actively seeking guidance on how to implement VPN detection. Kindly if someone can guide me it would be appreciated

#62
Quote from: habi on Jul 16, 2023, 05:15 AM@Mohamed Boubekri, there is error in your code.

I think the error caused by wepname+=...

Put that line under else of if statement.

You are not getting Rocket Launcher - Only the message!
Damn, thank you habi its works

@Mohamed Boubekri thanks for your efforts too bro
#63
In my server you have to purchase 2 weapons 
1) Rocket Launcer
2) Chainsaw

I've tried to modify spawnwep to prevent saved these weapons from player's spawnwep

when player tried to add these blocked weapons by /spawnwep m60 rocket it showed
You have to buy Rocket Launcher from the ammunation

but on the next moment it shows

You have set your spawnwep weapons to m60, RocketLauncher

I want spawnwep to highlight only the weapon which is not blocked and ignore these two weapons




here's my modify code

else if (cmd == "spawnwep") {
    if (text) {
        QuerySQL(db, "UPDATE SpawnWep SET Wep1='0',Wep2='0',Wep3='0',Wep4='0',Wep5='0',Wep6='0',Wep7='0',Wep8='0',Wep9='0' WHERE Name LIKE '" + escapeSQLString(player.Name) + "'");
        local ptext = split(text " ");
        spawnwep[player.ID].SpawnWepStatus = true;
        QuerySQL(db, "UPDATE SpawnWep SET SpawnWepStatus='true' WHERE Name LIKE '" + escapeSQLString(player.Name) + "'");
        local wepnames = "";
        local weaponsSet = false;  // Flag to track if any weapons were successfully set
        foreach (wep in ptext) {
            local weaponId = IsNum(wep) ? wep.tointeger() : GetWeaponID(wep);
            wepnames += wepnames != "" ? format(", %s", GetWeaponName(weaponId)) : GetWeaponName(weaponId);
            if (weaponId == 33) {
                ClientMessage("[#ea4335]-> Error: [#c0c0c0]Invalid Weapon ID/Name.", player, 0, 0, 0);
            } else if ( weaponId == 30 || weaponId == 11) {
                ErrorMessage("[#FF0000][Server] - [#FFFFFF]You have to buy [ " +GetWeaponName(weaponId)+ " ] from the ammunation", player);
            } else {
                QuerySQL(db, "UPDATE SpawnWep SET " + GetWepColumn(GetWeaponSlot(weaponId)) + "='" + weaponId + "' WHERE Name LIKE '" + escapeSQLString(player.Name) + "'");
                player.SetWeapon(weaponId, 99999);
                weaponsSet = true;  // Set the flag to true if at least one weapon is successfully set
            }
        }
        local q = QuerySQL(db, "SELECT * FROM SpawnWep WHERE Name = '" + escapeSQLString(player.Name) + "'");
        if (q != null) {
            spawnwep[player.ID].SpawnWeps = [GetSQLColumnData(q, 2).tointeger(), GetSQLColumnData(q, 3).tointeger(), GetSQLColumnData(q, 4).tointeger(), GetSQLColumnData(q, 5).tointeger(), GetSQLColumnData(q, 6).tointeger(), GetSQLColumnData(q, 7).tointeger(), GetSQLColumnData(q, 8).tointeger(), GetSQLColumnData(q, 9).tointeger(), GetSQLColumnData(q, 10).tointeger()];
        }
        if (weaponsSet) {  // Only display the success message if at least one weapon is successfully set
            MessagePlayer("[#00FF00][SPAWN WEP]: [#FFFFFF]You have set your spawn weapons to " + wepnames + " successfully!", player);
        }
        return 0;
    } else {
        MessagePlayer("[#FFFF00]Syntax: /spawnwep <Weps Name/ID>", player);
    }
}

Spawnwep i used
https://forum.vc-mp.org/index.php?topic=8846.msg52222#msg52222
#64
Quote from: habi on Jul 11, 2023, 04:35 AMFor the rocket, the slot is 7.

Thank you so much
 How do I know about other weapons slots? Can you please show me where I can get the list?
#65
How do i make give you more ammo for the Rocket Launcher or remote when you buy more rockets/remote
else if (cmd == "buywep")
{
    if (!text)
        return ErrorMessage("[#FF0000][Server] - [#FFFFFF]/" + cmd + " <remote/rocket>", player);
    else if (status[player.ID].buywep == false)
        MessagePlayer("[#FF0000][Error] - [#FFFFFF] You must be at ammunation to buy this wep", player);
    else
    {
        if (text == "remote")
        {
            if (player.Cash >= 20000)
            {
                ClientMessage("-> [#daff00]** Successfully purchased Remote Grenade", player, 255, 0, 102);
                player.SetWeapon(13, 10);
                RemoveCash(player, 20000);
            }
            else
            {
                MessagePlayer("[#FF0000]You need at least $20000 to buy remote grenade", player);
            }
        }
        else if (text == "rocket")
        {
            if (player.Cash >= 10000)
            {
                ClientMessage("-> [#daff00]** Successfully purchased Rocket Launcher", player, 255, 0, 102);
                player.SetWeapon(30, 10);
                RemoveCash(player, 10000);
            }
            else
            {
                MessagePlayer("[#FF0000]You need at least $10000 to buy Rocket Launcher", player);
            }
        }
    }
}
#66
Quote from: habi on Jul 10, 2023, 03:58 AMchange
local diffMonths = currentTime.month + 1- createdMonth;because squirrel date() returns month as 0-11 (not as 1 - 12) as seen http://squirrel-lang.org/squirreldoc/stdlib/stdsystemlib.html?highlight=date#date
Thank you so much habi its works. Will gives you credits
#67
Quote from: 2b2ttianxiu on Jul 09, 2023, 07:02 PMYou cannot use sqlite include timestamp, it cannot convert to number
You must change column data tag (numeric default 0)
and insert or update data, you use 'time().tointeger()' to update this data
did you mean ?
 Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP

can you please explain little bit ?
#68
Hy I am trying to convert 2023-07-08 16:25:06 into months days and years like

2020-07-07 16:25:06 = 3 years 3 days ago

But the script gave me WRONG date, I entered the data today 2023-07-08 16:25:06 but saying 11 Months AGO

is it a problem in the Code or in the database ??

function GetTimeFormat2(CreatedAt) {
 
    local currentTime = date();
    local createdYear = CreatedAt.slice(0, 4).tointeger();
    local createdMonth = CreatedAt.slice(5, 7).tointeger();
    local createdDay = CreatedAt.slice(8, 10).tointeger();

    local diffYears = currentTime.year - createdYear;
    local diffMonths = currentTime.month - createdMonth;
    local diffDays = currentTime.day - createdDay;

    if (diffMonths < 0) {
        diffYears--;
        diffMonths += 12;
    }
    if (diffDays < 0) {
        diffMonths--;
        diffDays += ::daysinmonth(createdYear + diffYears, createdMonth + diffMonths);
    }

    local timeString = "";

    if (diffYears > 0) {
        timeString += diffYears + " Year" + (diffYears > 1 ? "s" : "") + " ";
    }
    if (diffMonths > 0) {
        timeString += diffMonths + " Month" + (diffMonths > 1 ? "s" : "") + " ";
    }
    if (diffDays > 0) {
        timeString += diffDays + " Day" + (diffDays > 1 ? "s" : "") + " ";
    }

    if (timeString == "") {
        timeString = "Just now";
    } else if (diffYears == 0 && diffMonths == 0 && diffDays == 0) {
        timeString = "Today";
    } else {
        timeString += "ago";
    }

    return timeString;
}

Function to retrieve data

b = b + " \n" + GetSQLColumnData(q, 0) + " " + GetTimeFormat2(GetSQLColumnData(q, 1))




#69
Quote from: habi on Jul 08, 2023, 01:45 PMNihongo, you must learn what you are doing.
So check the code, what it is doing etc and give a try.
We help those who help themselves.
I understand i will check it

Thank you
#70
I made a cmd for discord to retrieve the data of a player

Its works only when i put the UID and IP address but when i put the nick it said

 No player information found
i just want to merge all in one cmd ip uid and nick

!alias  <Nick/UID/IP>
case "alias":
    if (highestRole.GetLevel() < 2) sendMessage(channels["staffchat"], "You do not have permission to use this command.");
    else if (!text) sendMessage(channels["staffchat"], "**USAGE**: !" + cmd + " <Nick/UID/IP>");
    else {
        local b = "";
        local a = 0;

        // Search for players with the same UID
        local q1 = ::QuerySQL(db, "SELECT Name, IP FROM Alias WHERE UID='" + ::escapeSQLString(text) + "'");
        while (::GetSQLColumnData(q1, 0) != null) {
            if (b) {
                b = b + "\nName: " + ::GetSQLColumnData(q1, 0) + " | IP: " + ::GetSQLColumnData(q1, 1);
            } else {
                b = "Name: " + ::GetSQLColumnData(q1, 0) + " | IP: " + ::GetSQLColumnData(q1, 1);
            }
            ::GetSQLNextRow(q1);
            a++;
        }
        ::FreeSQLQuery(q1);

        // If no players with the same UID are found, search for players within the same subnet
        if (a == 0) {
            local q2 = ::QuerySQL(db, "SELECT Name, IP FROM Alias WHERE IP LIKE '" + ::escapeSQLString(text) + "%'");
            while (::GetSQLColumnData(q2, 0) != null) {
                if (b) {
                    b = b + "\nName: " + ::GetSQLColumnData(q2, 0) + " | IP: " + ::GetSQLColumnData(q2, 1);
                } else {
                    b = "Name: " + ::GetSQLColumnData(q2, 0) + " | IP: " + ::GetSQLColumnData(q2, 1);
                }
                ::GetSQLNextRow(q2);
                a++;
            }
            ::FreeSQLQuery(q2);
        }

        if (a >= 1) {
            embed.SetTitle("Player information for: " + text);
            embed.SetColor(0xE3554B);
            embed.SetDescription(b);
            sendEmbed(channels["staffchat"], embed);
        } else {
            sendMessage(channels["staffchat"], "No player information found for: " + text);
        }
    }
   
#71
Quote from: habi on Jul 06, 2023, 10:58 AMlocal query = ::QuerySQL(db, "SELECT IP FROM Alias WHERE Name = '" + plr + "' ORDER BY CreatedAt DESC LIMIT 1");

Thank you so much habi <3
#72
Quote from: habi on Jul 06, 2023, 10:24 AMBecause it is searching for a column.
I did not understand you ? the name is already in the column?

local query = ::QuerySQL(db, "SELECT IP FROM Alias WHERE Name = '" + plr + "'Timestamp DESC LIMIT 1");
It still saying There's no such name existing in the database
#73
Quote from: habi on Jul 06, 2023, 10:01 AMThat field will automatically inserted when a new row is supplied.
Revert code of function back.
Thanks it works

 but when i try to retrieve the latest IP it said There's no such name existing in the database  ??? 

case "ogetip":
if (highestRole.GetLevel() < 2) sendMessage(channels["staffchat"], "You do not have permission to use this command.");
else if (!text) sendMessage(channels["staffchat"], "**USAGE**: !"+ cmd +" <Full Nick>");
else {
local plr = GetTok(text, " ", 1);
local query = ::QuerySQL(db, "SELECT IP FROM Alias WHERE Name = '" + plr + "' ORDER BY Timestamp DESC LIMIT 1");
local latestIP = ::GetSQLColumnData(query, 0);
if (!query) {
sendMessage(channels["staffchat"], "[Error] There's no such name existing in the database.");
} else {
sendMessage(channels["staffchat"], "Player [" + plr + "] is using the latest IP: [" + latestIP + "]");
}
}
}
#74
Quote from: habi on Jul 06, 2023, 07:30 AM1. drop the table called Alias
2. CREATE TABLE Alias(
    name ...,
    ip ...,
    uid ...,
    Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);

I tried but it said CURRENT_TIMESTAM doesn't not exist.

QuerySQL(db, "CREATE TABLE IF NOT EXISTS Alias (Name TEXT, IP VARCHAR(20), UID TEXT, CreatedAt DATETIME DEFAULT CURRENT_TIMESTAMP)");

and function

function AddAlias(player) {
    local q = QuerySQL(db, "SELECT * FROM Alias WHERE Name='" + player.Name + "'");
    if (!GetSQLColumnData(q, 0)) {
 QuerySQL(db, "INSERT INTO Alias (Name, IP, UID, CreatedAt) VALUES ('" + player.Name + "', '" + player.IP + "', '" + player.UniqueID + "', '" + CURRENT_TIMESTAMP +"')")
    } else {
local q = QuerySQL(db, "SELECT * FROM Alias WHERE Name='" + player.Name + "' AND UID='" + player.UniqueID + "'");
    if (!GetSQLColumnData(q, 0)) {
QuerySQL(db, "INSERT INTO Alias (Name, IP, UID, CreatedAt) VALUES ('" + player.Name + "', '" + player.IP + "', '" + player.UniqueID + "', '" + CURRENT_TIMESTAMP +"')")
    }else {
q=QuerySQL(db, "SELECT * FROM Alias WHERE Name='"+player.Name+"' AND IP='"+player.IP+"'");
if (!GetSQLColumnData(q, 0)) {
QuerySQL(db, "INSERT INTO Alias (Name, IP, UID, CreatedAt) VALUES ('" + player.Name + "', '" + player.IP + "', '" + player.UniqueID + "', '" + CURRENT_TIMESTAMP +"')")
    }
}
}
}

#75
Quote from: habi on Jul 04, 2023, 04:36 PMdo it like this:local q = QuerySQL(db, "SELECT * FROM Alias WHERE Name='" + player.Name + "' AND IP='" + player.IP + "'");
    if (!GetSQLColumnData(q, 0)) {
        QuerySQL(db, "INSERT INTO Alias (Name, IP, UID) VALUES ('" + player.Name + "', '" + player.IP + "', '" + player.UniqueID + "')");
    }else {
q=QuerySQL(db, "SELECT * FROM Alias WHERE Name='"+player.Name+"' AND UID='"+player.UniqueID+"'");
if (!GetSQLColumnData(q, 0)) {
        QuerySQL(db, "INSERT INTO Alias (Name, IP, UID) VALUES ('" + player.Name + "', '" + player.IP + "', '" + player.UniqueID + "')");
    }
}

Its work Thank you so much

Just last question i want to grab the latest IP used by the player can you please guide me on it ?

case "ogetip":
if (highestRole.GetLevel() < 2) sendMessage(channels["staffchat"], "You do not have permission to use this command.");
else if (!text) sendMessage(channels["staffchat"], "**USAGE**: !"+ cmd +" <Full Nick>");
else
{
   local plr = GetTok( text, " ", 1 );
  local query = ::QuerySQL(db, "SELECT IP FROM Alias WHERE Name = '" + plr + "' ORDER BY Timestamp DESC LIMIT 1");
local latestIP = ::GetSQLColumnData(query, 0);
if (!query) {
sendMessage(channels["staffchat"], "[Error] There's no such name existing in the database.");
} else {
sendMessage(channels["staffchat"], "Player [" + plr + "] is using the latest IP: [" + latestIP + "]");
}
}
break;

I tried but not work it said  There's no such name existing in the database when i remove "ORDER BY Timestamp DESC LIMIT 1" it give me the ip but not the latest