Recent posts

#1
Script Showroom / Script Automatically Fixes Sys...
Last post by PSL - Apr 19, 2024, 08:52 AM
When your script goes wrong, the system finds the wrong code, deletes it, and then restarts the server.
function ReloadServer()
{
    local loaded=[];
    for(local i=0;i<100;i++)
    {
        local plr=FindPlayer(i);
        if(plr)
        {
            loaded.append(plr.ID);
            if(plr.Vehicle) plr.Eject();

            onPlayerPart(plr,0);
        }
    }

    onScriptUnload();
    onServerStop();
    dofile("scripts/main.nut");
    onScriptLoad();
    onServerStart();

    for(local i=0;i<loaded.len();i++)
    {
        local plr=FindPlayer(loaded[i]);
        if(plr)
        {
            onPlayerJoin(plr);
            onPlayerRequestClass(plr,plr.Class,plr.Team,plr.Skin);
            if(plr.IsSpawned==true) onPlayerSpawn(plr);
        }
    }
    AnnounceAll("~p~Server Reload!",3);
}

function ReadTextFromFile(path)
{
    local f=file(path,"rb"),s ="",n=0;
    f.seek(0,'e');
    n=f.tell();
    if(n==0) return s;
       
    f.seek(0,'b');
    local b=f.readblob(n+1);
    f.close();
    for(local i=0;i<n;++i) s+=format(@"%c",b.readn('b'));
    return s;
}

function WriteTextToFile(path,text)
{
    local f=file(path,"wb+"),s="";
    f.seek(0,'e');
    foreach(c in text) f.writen(c,'b');
    f.close();
}

function errorfixer(str)
{
local stackinfo,stacktrace="[Error]\n"+str+"\n[Functions]",locals="\n[Locals]",linearr=[];
for(local i=2;stackinfo=getstackinfos(i);i++)
{
stacktrace+="\n["+stackinfo["func"]+"()] "+stackinfo["src"]+" ["+stackinfo["line"]+"]";
linearr.append(stackinfo["line"].tointeger());
foreach(idx,val in stackinfo["locals"]) locals+="\n["+stackinfo["func"]+"]"+idx+", Value="+val+"";
}
print(stacktrace+locals);

    local script=ReadTextFromFile("scripts/main.nut");
    local arr=split(script,"\n"),data="";
    for(local i=1;i<arr.len()+1;i++)
    {
        local find=false;
        for(local ii=0;ii<linearr.len();ii++)
        {
            if(i==linearr[ii].tointeger())
            {
                find=true;
                break;
            }     
            if(find==false)
            {
                data+=arr[i-1];
                break;
            }
        }
    }
    WriteTextToFile("scripts/main.nut",data);
    ReloadServer();
}
seterrorhandler(errorfixer);
#2
sorry if I posted in wrong board, I need the script for science
#3
Scripting and Server Management / Re: How to unload scripts?
Last post by PSL - Mar 24, 2024, 02:38 PM
I'm looking into this plugin: https://forum.vc-mp.org/index.php?topic=9181.0
I'll publish the results within 90 days.
#4
Off-Topic General / Asian City Triple Clash - ACTC...
Last post by Broly. - Mar 24, 2024, 08:07 AM
🎉🌟 Attention VCMP Clan Members! You're Invited to the Asian City Triple Clash - ACTC Event! 🌟🎉

How it Works:
Join our AC discord: https://discord.gg/4geCusrX


Gather your team of 3 or 4, including the captain.
Copy and fill out the format in the ⁠team-applications board.
Interested in becoming a referee? Copy and fill out the format in the ⁠referee-applications  board.
Each team can have 4 players (including the captain), with 3 players playing and 1 player as a sub.


Prizes:
Winning Team:15USD Dollars, $2M, a Hydra, and a Ferrari vehicle.

Runner-up Team: $1M and an Infernus Vehicle.

Match Hosting:
Format: 3 vs 3.
Limited weapons during matches.
Each match consists of 3 rounds, each lasting 15 minutes.
Scoring: Each kill earns 1 point, while spree will give you +3 score.

Server IP : 162.19.27.237:8192

Last Date to Apply : 27/03/2024
For more Info you can Check

ACTC-information


#5
Script Showroom / Re: BindKey Process System
Last post by PSL - Mar 24, 2024, 12:45 AM
I updated the function to set the number of repetitions, Make adding code easier.
AddKeyToTable(Key_K,10); //When K is pressed, it is automatically executed 10 times.
Create nut to scripts folder gift, name is keyprocess.nut.

//by: https://forum.vc-mp.org/index.php?topic=9397.0
//Function
/*
AddKeyToTable(key); //Set a key to repeat
AddKeyToTable(key,processtimes); //Set the key to repeat and set the number of repetitions
DeleteKeyToTable(key); //Delete the duplicate function of the key
SetKeyExecTime(time); //Set the interval for automatic execution
*/

function LoadKeyProcess()
{
ProcessKey<-{}; //Records repeatable keys
ProcessKeyTime<-10; //Execution interval milliseconds
ProcessKeyTimer<-null; //Execute key timer

PlayerKeys<-{}; //Record the keys pressed by the player

ProcessKeyExecTimes<-{}; //Records the number of key executions
PlayerKeyExecTimes<-array(100,null); //Record the number of times a player executes each key
}

function AddKeyToTable(key,processtimes=null)
{
ProcessKey.rawset(key,key);
if(processtimes!=null) ProcessKeyExecTimes.rawset(key,processtimes);
}

function DeleteKeyToTable(key)
{
if(ProcessKey.rawin(key)) ProcessKey.rawdelete(key);
if(ProcessKeyExecTimes.rawin(key)) ProcessKeyExecTimes.rawdelete(key);
}

function SetKeyExecTime(times)
{
if(times<0) times=1;
ProcessKeyTime=times;
}

function AddPlayerKeyToTable(i,key)
{
local plr=FindPlayer(i);
if(plr)
{
if(ProcessKey.rawin(key))
{
if(PlayerKeys.rawin(plr.ID))
{
local arr=PlayerKeys.rawget(plr.ID),find=false;
for(i=0;i<arr.len();i++)
{
if(arr[i]==key)
{
find=true;
break;
}
}
if(find==false) arr.append(key);
}
else
{
local arr=[];
arr.append(key);
PlayerKeys.rawset(plr.ID,arr);
}

if(ProcessKeyExecTimes.rawin(key))
{
if(PlayerKeyExecTimes[plr.ID]==null) PlayerKeyExecTimes[plr.ID]={};
if(PlayerKeyExecTimes[plr.ID].rawin(key))
{
local times=PlayerKeyExecTimes[plr.ID].rawget(key);
times-=1;
PlayerKeyExecTimes[plr.ID].rawset(key,times);
}
else
{
local keytimes=ProcessKeyExecTimes.rawget(key);
PlayerKeyExecTimes[plr.ID].rawset(key,keytimes);
}
}
CreateProcessKeyTimer();
}
}
}

function DeletePlayerKeyToTable(i,key)
{
local plr=FindPlayer(i);
if(plr)
{
if(ProcessKey.rawin(key))
{
if(PlayerKeys.rawin(plr.ID))
{
local arr=PlayerKeys.rawget(plr.ID);
for(local i=0;i<arr.len();i++)
{
if(arr[i]==key)
{
arr.remove(i);
break;
}
}
if(arr.len()==0) PlayerKeys.rawdelete(plr.ID);
}
if(ProcessKeyExecTimes.rawin(key))
{
if(PlayerKeyExecTimes[plr.ID]!=null)
{
if(PlayerKeyExecTimes[plr.ID].rawin(key))
{
PlayerKeyExecTimes[plr.ID].rawdelete(key);
if(PlayerKeyExecTimes[plr.ID].len()==0) PlayerKeyExecTimes[plr.ID]=null;
}
}
}
if(PlayerKeys.len()==0) DeleteProcessKeyTimer();
}
}
}

function DeleteAllPlayerKeyToTable(i)
{
local plr=FindPlayer(i);
if(plr)
{
if(PlayerKeys.rawin(plr.ID)) PlayerKeys.rawdelete(plr.ID);
if(PlayerKeyExecTimes[plr.ID]!=null) PlayerKeyExecTimes[plr.ID]=null;
}
}

function CreateProcessKeyTimer()
{
if(ProcessKeyTimer==null) ProcessKeyTimer=NewTimer("onServerKeyProcess",ProcessKeyTime,0);
}

function DeleteProcessKeyTimer()
{
if(ProcessKeyTimer!=null) ProcessKeyTimer.Delete();
ProcessKeyTimer=null;
}

function onServerKeyProcess()
{
for(local i=0;i<100;i++)
{
local plr=FindPlayer(i);
if(plr)
{
if(PlayerKeys.rawin(plr.ID))
{
local arr=PlayerKeys.rawget(plr.ID);
for(local i=0;i<arr.len();i++)
{
local find=false;
if(ProcessKeyExecTimes.rawin(arr[i]))
{
if(PlayerKeyExecTimes[plr.ID]!=null)
{
if(PlayerKeyExecTimes[plr.ID].rawin(arr[i]))
{
local keytimes=PlayerKeyExecTimes[plr.ID].rawget(arr[i]);
if(keytimes<0) find=true;
}
}
}
if(find==false) onKeyDown(plr,arr[i]);
}
}
}
}
}

LoadKeyProcess();

Add in main.nut
function onScriptLoad()
{
dofile("scripts/keyprocess.nut");
}
function onPlayerPart(player,reason)
{
DeleteAllPlayerKeyToTable(player.ID);
}
function onKeyDown(player,key)
{
AddPlayerKeyToTable(player.ID,key);
}
function onKeyUp(player,key)
{
DeletePlayerKeyToTable(player.ID,key);
}

Very simple way to add. You can customize the key Settings according to the previous code.
#6
Script Showroom / Re: Ammunation Ready!
Last post by Abbas_905 - Mar 20, 2024, 08:01 AM
pro
#7
Script Showroom / Transferstats Command
Last post by Abbas_905 - Mar 20, 2024, 04:08 AM
else if ( cmd == "transferstats" )
{
       if ( !text ) MessagePlayer("Error: Please use the correct syntax.  /transferstats <newnick>.", player );
       else
       {
       local newnick = text,
       pn = QuerySQL(sqliteDB, " SELECT Name FROM Accounts WHERE Name='"+player.Name+"' "),
       n = QuerySQL(sqliteDB, " SELECT Name FROM Accounts WHERE Name='"+newnick+"' "),
       aldname = GetSQLColumnData(n, 0),
       oldname = GetSQLColumnData(pn, 0);
       if ( newnick == player.Name ){
       MessagePlayer("Error: Your new name cannot be the same nickname.",player); return false;}
       else if ( aldname != null ) { MessagePlayer("Error:This name is already registered by someone.",player); return false;}
else
{
QuerySQL(sqliteDB, "UPDATE Accounts SET Name='"+newnick+"', NameLower='"+newnick.tolower() +"'  WHERE Name='"+oldname+"' ");
         QuerySQL(Spawnweps, "UPDATE SpawnWep SET Name='"+newnick+"' WHERE Name='"+oldname+"' ");
         QuerySQL(SpawnLoc, "UPDATE Spawnloc SET player='"+newnick+"' WHERE player='"+oldname+"'");
         player.Name=text;
         MessagePlayer("Successfully changed your nickname to " + newnick  +"!",player);
         }
         FreeSQLQuery( pn );
         FreeSQLQuery( n );
         }
         }
#8
Script Showroom / Re: Dipeos command
Last post by Abbas_905 - Mar 19, 2024, 03:50 PM
Bro so now u and some others gived me functions not diepos command u can give me?  :(
#9
Script Showroom / Re: BindKey Process System
Last post by Mohamed Boubekri - Mar 18, 2024, 10:22 AM
Setting the time during a key press is a very useful feature to prevent occasional hacking or delays in some scripts.
good job.
#10
Script Showroom / Re: Dipeos command
Last post by PSL - Mar 16, 2024, 08:45 AM
This script has no language formatting errors.