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

#1
Hi, i just tried this function to reload my script https://forum.vc-mp.org/index.php?topic=9251.msg53101#msg53101

but the problem is its wont save the data after the player rejoin
In this pic i killed my self after reload the script but it didn't save the data "death" in the database
 


P.S I only add onPlayerCommand, getOnlinePlayers,getPlayer(object)  and ignore the rest

"In main.nut"

#2
Hi how do i make limit for pressing "J" button ?

like player can Press only 5 or 4 times for jump or boost


function onKeyDown( player, oldKeys, newKeys )
{
  if( key == J )
    {
      if( player.Vehicle )
      {
        local vPos   = player.Vehicle.Pos;
        vPos.z = vPos.z * 1.5;
      }
    return;
    }
  }
#3
i have problem in /spec
when player died the spec system stopped working its due to player.world = 2
i used plr.Word =2 for anti spawn killing

so when player spawn spec stop working

how do i make it work again ? as the player.wolrd = 2 take 3 seconds to send the world 1
so i want to it work again without waiting for the plr to set world 1
function AntiSpawn(player)
{
player.World = 2;

NewTimer( "AntiSpawnOff", 5000, 1, player.ID );
Announce( "~o~ SPAWN PROTECTION IS ON !" , player);
player.CanAttack = false;
}

function AntiSpawnOff( player )
{
local plr = FindPlayer(player);
if(plr) {
plr.World = 1;
Announce( "~G~ SPAWN PROTECTION IS OFF !" ,plr );
plr.CanAttack = true;
}
}
function onPlayerSpawn( player )
{
AntiSpawn(player)
}
#4
My temp ban is working perfectly but whenver this guy name "[THC]^CUTE^295" joins the server  it gives an error here

local banType = GetSQLColumnData(q, 9).tostring();

Here's my full checktempban function

function CheckTempBan(player) {
    local q = QuerySQL(db, "SELECT * FROM TempBans WHERE Name='" + escapeSQLString(player.Name) + "' OR IP='" + escapeSQLString(player.IP) + "' OR UID='" + escapeSQLString(player.UniqueID) + "' OR UID2='" + escapeSQLString(player.UniqueID2) + "'");
    if (q) {
        local banType = GetSQLColumnData(q, 9).tostring(); <--- Line 518
                local currentTime = time();
            local banStartTime = GetSQLColumnData(q, 4).tointeger();
            local banDuration = GetSQLColumnData(q, 5).tointeger();
            if (currentTime - banStartTime >= banDuration) {
                QuerySQL(db, "DELETE FROM TempBans WHERE LOWER(Name)='" + player.Name.tolower() + "'");
            } else {
                local timeLeft = banDuration - (currentTime - banStartTime);
                ServerMessage("[#FF0000][PRIOR BAN]: [#FFFFFF] [ " + player.Name + " ] is banned for Reason: [ " + GetSQLColumnData(q, 8) + " ]");
                ServerMessage("[#FF0000][PRIOR BAN]: [#FFFFFF] TimeLeft: [ " + GetBanRemainingTime(GetSQLColumnData(q, 4).tointeger(), GetSQLColumnData(q, 6).tostring()) + " ], Admin: [ " + GetSQLColumnData(q, 7) + " ]");
                EchoMessage("[PRIOR BAN]: [ " + player.Name + " ] is banned for Reason: [ " + GetSQLColumnData(q, 8) + " ] TimeLeft: [ " + GetBanRemainingTime(GetSQLColumnData(q, 4).tointeger(), GetSQLColumnData(q, 6).tostring()) + " ], Admin: [ " + GetSQLColumnData(q, 7) + " ]");
        player.Kick();         
        }
        }
        }
        }

Kindly explain me about "tostring();" is it really necessary ? and what is it ?
Thank you in advance
#5
There's a "comma" in the duration bracket

Nick: Time left  [ , 2 Years, 8 Months, 1 Weeks, 1 Days ]

How do I remove it?

ServerMessage("[#FF0000][PRIOR BAN]:[#FFFFFF] [ " + player.Name + " ] is banned for Reason: [ " + GetSQLColumnData(q, 8) + " ] ]");
         ServerMessage("[#FF0000][PRIOR BAN]:[#FFFFFF] TimeLeft: [ " + GetBanRemainingTime(GetSQLColumnData(q, 4).tointeger(), GetSQLColumnData(q, 6).tostring()) + " ], Admin: [ " + GetSQLColumnData(q, 7) + " ]");
function GetBanRemainingTime( bantime,  banratio )
{
  local ban_current = time()-bantime;
  local total_time = "";
  local sp = split(banratio,":");
  local ban_Days = 0, ban_Hours = 0, ban_Minutes = 0;
  local ban_Day = sp[ 0 ].tointeger();
  local ban_Hour = sp[ 1 ].tointeger();
  local ban_Minute = sp[ 2 ].tointeger();
  ban_Days = ban_current/86400;
  ban_current = ban_current%86400;
  ban_Hours = ban_current/3600;
  ban_current = ban_current%3600;
  ban_Minutes = ban_current/60;
  ban_current = ban_current%60;
  ban_Day -= ban_Days;
  ban_Hour -= ban_Hours;
  ban_Minute -= ban_Minutes;
  local mints_to_hour = ban_Minute / 60;
  ban_Minute = ban_Minute - (mints_to_hour * 60);
  ban_Hour += mints_to_hour;
  local hours_to_days = ban_Hour / 24;
  ban_Hour = ban_Hour - (hours_to_days * 24);
  ban_Day += hours_to_days;
  local months = ban_Day / 31;
  ban_Day = ban_Day - (months * 31);
  local weeks = ban_Day / 7;
  ban_Day = ban_Day - (weeks * 7);
  local years = months / 12;
  months = months - (years * 12);
  if(years > 0) total_time += ", "+years+" Years";
  if(months > 0){if(total_time != ""){total_time += ", "+months+" Months";}else{total_time += months+" Months";}}
  if(weeks > 0){if(total_time != ""){total_time += ", "+weeks+" Weeks";}else{total_time += weeks+" Weeks";}}
  if(ban_Day > 0){if(total_time != ""){total_time += ", "+ban_Day+" Days";}else{total_time += ban_Day+" Days";}}
  if(ban_Hour > 0){if(total_time != ""){total_time += ", "+ban_Hour+" Hours";}else{total_time += ban_Hour+" Hours";}}
  if(ban_Minute > 0){if(total_time != ""){total_time += ", "+ban_Minute+" Minutes";}else{total_time += ban_Minute+" Minutes";}}
  return total_time;
}

P.S Its only showing command in "years" other wise no comma in months weeks or day
#6
Hy, every time I lose my players, whenever I restart my server from the control panel.

So I found this script in the forum, thinking it would help me to reload the script without losing players

But it gives me an error
case "reload":
if (highestRole.GetLevel() < 2) sendMessage(channels["staffchat"], "You do not have permission to use this command.");
else
  {
::onScriptUnload();
::ReloadScripts()
}
Fu error The index Disconnect SQL: does not exist


#7
How do i restrict /skin when player fall down (player on ground after getting hit with weapon ) ?

Most of players in my server do evade with /skin <id>. It immediately change the skin and player get up on exact moment

i made this one but it works only for 1 second and after that player can use skin ( it take around 4/5 seconds for the player to get up properly and run )
if (cmd == "skin") {
        if (player.Action == 42) {
            MessagePlayer("You cannot use /skin while on the ground.", player);
            return;
        }
}
#8
How do I kick players containing number nicks?
And nicks with weird symbols ( ,,,' ''''' """" )
#9
In 0.3, there's a function named "OnPlayerFall."

when a player fell down ( from the building or someone shot him with Stuby or shotgun etc.)

I just realized that 0.4 no longer supports it; I would like to ask if there is any alternative to this function.

I use it, but nothing seems to appear.


}
function onPlayerFall(player)
{
    MessagePlayer("You fall down");
}

 
#10
After spending hours to making VPN detection now, I am facing this segmentation fault in the Linux after this message server get closed
This error only occurs on this line onPlayer join
  request.sendGet();
and here the full function
function onPlayerJoin( player )
{
   local playerIP = "195.146.4.43";
    // Replace "YOUR_API_KEY" with your actual proxycheck.io API key
    local api_key = "798233-593822-1490lk-681482";

    local url = "https://proxycheck.io/v2/" + playerIP + "?vpn=1&asn=1&key=" + api_key;

    // Make the HTTP request to proxycheck.io
    local request = ::SqHTTP.GetRequest();
    request.setURL(url);
    request.setTag("proxy_check_request");
    request.sendGet();

}


#11
In the refer of t his https://forum.vc-mp.org/index.php?topic=9275.0

I want to say thanks to @habi and @vitovc for the help.

I tried to utilize the function and made a code it detecting its as a proxy, but in print, it said
not using a proxy

While I've provided a proxy IP and it detected




Function

function HTTP_OnResponse(tag, url, statusCode, response)
{
    print("Data received for request with tag " + tag);
    print("Response: " + response);
   
    if (tag == "proxy_check_request")
    {
        // Check if the request was successful
        if (statusCode == 200)
        {
            local findProxy = response.find("proxy");
            if (findProxy == "yes")
            {
//Player is using a proxy
                    print("Using a proxy.");
                }
                else
                {
                    // Player is not using a proxy
                    print("Not using a proxy.");
                }
            }
        else
        {
            // Handle HTTP request error
            print("Proxy check request failed with status code " + statusCode);
        }
    }
}


#12
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

#13
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
#14
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);
            }
        }
    }
}
#15
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))




#16
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);
        }
    }
   
#17
Hi, I made some modifications to inserting alias in the database.

I want a new entry whenever the player's IP or UID changes, but I know when the script reads the first entry ( where IP is changed), it kept entering the new try whenever the player joined.

Quotefunction 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) VALUES ('" + player.Name + "', '" + player.IP + "', '" + player.UniqueID + "')");
    } else {
        local currentIP = GetSQLColumnData(q, 1);
        local currentUID = GetSQLColumnData(q, 2);
       
        if (currentUID != player.UniqueID) {
            QuerySQL(db, "INSERT INTO Alias (Name, IP, UID) VALUES ('" + player.Name + "', '" + player.IP + "', '" + player.UniqueID + "')");
        } else if (currentIP != player.IP) {
            QuerySQL(db, "INSERT INTO Alias (Name, IP, UID) VALUES ('" + player.Name + "', '" + player.IP + "', '" + currentUID + "')");
        }
    }
}


#18
Hi, I am trying to make an offline temp ban with some of my stupid ideas in this method, I want IP and UID from the accounts or Aliases copied and pasted into the temp ban colume. Can anybody please help me with the offline ban system for discord ?

else if(cmd == "tempban")
{
if ( GetLevel( player ) < 3 )
{
ErrorMessage("[Server] - [#FFFFFF]You don't have access to use this Command.", player );
return;
}
if(text)
{
local plr = (GetTok(text, " ", 1)), expire = GetTok(text, " ", 2), reason = GetTok( text, " ", 3, NumTok( text, " " ) );
local q = QuerySQL(db, "SELECT * FROM TempBans WHERE Name='"+plr+"'");
if(!q)
{
if(plr)
{
if(expire)
{
if(reason)
{
local ban_expire = split(expire, ":");
if(NumTok(expire, ":") == 3)
{
if(IsNum(ban_expire[0]) && IsNum(ban_expire[1]) && IsNum(ban_expire[2]))
{
local calc = ((ban_expire[ 0 ].tointeger()*24*60*60) + (ban_expire[ 1 ].tointeger()*60*60) + (ban_expire[ 2 ].tointeger()*60));
local ip = QuerySQL(db, "SELECT IP FROM Accounts WHERE Name='" + plr + "'" );
local uid = QuerySQL(db, "SELECT UID FROM Accounts WHERE Name='" + plr + "'" );
local uid2 = QuerySQL(db, "SELECT UID2 FROM Accounts WHERE Name='" + plr + "'" );

QuerySQL( db, "INSERT INTO TempBans( Name, UID, UID2, IP, Time, ExpireTime, TimeExpireRatio, Admin, Reason ) VALUES ('"+plr+"', '"+uid +"', '"+uid+"', '"+ip+"', '"+time()+"', '"+calc+"', '"+expire+"', '"+player.Name+"', '"+reason+"')");

ServerMessage("[#FF0000][PRIOR BAN]: [#FFFFFF]"+plr+" is banned for Reason: "+reason+", TimeLeft: " + GetBanRemainingTime(time().tointeger(), expire.tostring())+", Admin: "+player.Name+"");
}
else ErrorMessage("[#FF0000][ERROR]: You've entered wrong values in the time, make sure you have entered numbers only!",player);
}
else ErrorMessage("[#FF0000][ERROR]: Time Format must be DAYS:HOURS:MINUTES!",player);
}
else ErrorMessage("[#FF0000][ERROR]: You must specify a reason to ban requested player!",player);
}
else ErrorMessage("[#FF0000][ERROR]: Please type the duration of the ban for the requested player!",player);
}
else ErrorMessage("[#FF0000][ERROR]: Unknown player!",player);
}
else ErrorMessage("[#FFFF00]Syntax; /tempban <player/ID> <Days:Hours:Minutes> <Reason>",player);
}
else ErrorMessage("[#FFFF00]Syntax; /tempban <player/ID> <Days:Hours:Minutes> <Reason>",player);
}


#19
Hi i am using this bank gate system with pickup

https://forum.vc-mp.org/index.php?topic=4261.msg31519#msg31519

The problem is pickup inside disappear it self and there's no way to go outside. How do i fix it ? it was working before but after few moment it disappear

#20
How do we prevent hackers?

Most people come with HP and Speed hacks, and the servers cannot detect them. So how do we solve this problem? Why did the server does not detect them?