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 - PSL

#1
I think in...squirrel04rel64.dll To add some functions.
I successfully compiled through the source code, but I do not know how to add a custom function in the source code, I want to add a function to disable the player key in the source code, how should I write?
#2
I tried to compile the makefile file in vscode, but the following problem occurred.Is there something wrong with the file itself?

C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe BITCOUNT=32 BUILDTYPE=rel xbuild
make[1]: Entering directory 'C:/Users/Administrator/Desktop/stormeus-0.4-announce-c1f737aaddce/0.4-announce' The command syntax is incorrect.
make[1]: *** [Makefile:56: objdir/rel32/./main.o] Error 1
make[1]: Leaving directory 'C:/Users/Administrator/Desktop/stormeus-0.4-announce-c1f737aaddce/0.4-announce'
make: *** [Makefile:32: build32] Error 2

I can compile the following normally:
main.cc
#include <stdio.h>

int main(int argc, char*argv[]) {
    printf("test\n");
    return 0;
}

Makefile
.PHONY: all clean

CC := gcc
CXX := g++
CFLAGS :=
CXXFLAGS := -gdwarf-4
Target := main

SRCS += $(wildcard *.cc)
OBJS := $(patsubst %.cc, %.o, ${SRCS})

all: $(Target)

$(Target): $(OBJS)
    $(CXX) $(CXXFLAGS) $(OBJS) -o $@

%.o: %.cc
    $(CXX) $(CXXFLAGS) -c $? -o $@

clean:
    rm -rf $(OBJS) $(Target)

#3
Hi Habi, NPC cannot enter the new server version 0.4.7.0
Console: Error server version: 67700. Using REL006 = 67400
#4
It seems that it is not possible to directly input noon, include in input fields and edit boxes.
How to achieve direct input and display of Chinese?
#5
This is my research code, I create a canvas and text, the default text is divided on the canvas, when I change the color of the canvas, the canvas comes over the text and it's blocked, I want the text to appear on top of the canvas I change the color, but after using these functions, nothing happens, okay.
function Script::ScriptLoad()
{
myCanvas<-GUICanvas();
myCanvas.Position=VectorScreen(0,0);
myCanvas.Size=VectorScreen(200,200);
myCanvas.Colour=Colour(45,45,45,100);

mylabel<-GUILabel();
mylabel.Text="Text Label";
mylabel.TextColour=Colour(255,255,255,255);
mylabel.FontSize=50;
mylabel.Pos=VectorScreen(0,0);

myCanvas.AddChild(mylabel);
}

function ChangeColour()
{
myCanvas.Colour=Colour(0,150,0,100);
mylabel.SendToTop();
}
#6
Function MoveForward()
Return type: void.
Moves the siblign element right in front of this one behind it.

Function MoveBackward()
Return type: void.
Moves the sibling element right behind this element to the front of it.

Function SendToTop()
Return type: void.
Moves this element on top of all other sibling elements.

Function SendToBottom()
Return type: void.
Moves this element to the bottom of all other sibling elements.

I tried to set up these functions for the GUI, the result is nothing changed, look at the meaning of this function can not understand, can anyone explain, thank you very much.
#7
I'm glad to see WIKI is back.
https://wiki.vc-mp.org/
#8
Client Scripting / Re: RGB Color Gradient
May 05, 2024, 03:04 AM
The code has been tested by blank service and is accurate and can be used with confidence.
#9
Client Scripting / RGB Color Gradient
May 05, 2024, 03:01 AM
Do you want your text or images, or other gui components to have RGB gradients?
The following code can get you inspired, but you can also use it in between.
The gradient order is white red orange yellow green cyan blue purple.

local serverlogor=255,serverlogog=255,serverlogob=255;
local rgblabel=null;

function Script::ScriptLoad()
{
rgblabel=GUILabel();
rgblabel.Pos=VectorScreen(250,450);
rgblabel.FontSize=40;
rgblabel.Text="Very cool gradient text";
rgblabel.TextColour=GetGradientRGB();
}

function Script::ScriptProcess()
{
UpdateRGB();
rgblabel.TextColour=GetGradientRGB();
}

function GetGradientRGB(alpha=255)
{
    return Colour(serverlogor,serverlogog,serverlogob,alpha);
}

function UpdateRGB()
{
    /* red to purple
    if(serverlogor==255&&serverlogog<255&&serverlogob==0)
    {
        serverlogog+=1;
        if(serverlogog==255) serverlogor-=1;
    }
    else if(serverlogor<255&&serverlogog==255&&serverlogob==0)
    {
        serverlogor-=1;
        if(serverlogor==0) serverlogob+=1;
    }
    else if(serverlogor==0&&serverlogog==255&&serverlogob>0)
    {
        serverlogob+=1;
        if(serverlogob==255) serverlogog-=1;
    }
    else if(serverlogor==0&&serverlogog<255&&serverlogob==255)
    {
        serverlogog-=1;
        if(serverlogog==0) serverlogor+=1;
    }
    else if(serverlogor>0&&serverlogog==0&&serverlogob==255)
    {
        serverlogor+=1;
        if(serverlogor==255) serverlogob-=1;
    }
    else if(serverlogor==255&&serverlogog==0&&serverlogob<255)
    {
        serverlogob-=1;
    }
    */

    // white to purple
    if(serverlogor==255&&serverlogog==255&&serverlogob==255)
    {
        serverlogog-=1;
        serverlogob-=1;
    }
    else if(serverlogor==255&&serverlogog<255&&serverlogob<255&&serverlogob!=0)
    {
        serverlogog-=1;
        serverlogob-=1;
        if(serverlogog==0&&serverlogob==0) serverlogog+=1;
    }
    else if(serverlogor==255&&serverlogog<255&&serverlogob==0)
    {
        serverlogog+=1;
        if(serverlogog==255) serverlogor-=1;
    }
    else if(serverlogor<255&&serverlogog==255&&serverlogob==0)
    {
        serverlogor-=1;
        if(serverlogor==0) serverlogob+=1;
    }
    else if(serverlogor==0&&serverlogog==255&&serverlogob>0)
    {
        serverlogob+=1;
        if(serverlogob==255) serverlogog-=1;
    }
    else if(serverlogor==0&&serverlogog<255&&serverlogob==255)
    {
        serverlogog-=1;
        if(serverlogog==0) serverlogor+=1;
    }
    else if(serverlogor>0&&serverlogog==0&&serverlogob==255)
    {
        serverlogor+=1;
        if(serverlogor==255) serverlogog+=1;
    }
    else if(serverlogor==255&&serverlogog<255&&serverlogob==255)
    {
        serverlogog+=1;
        if(serverlogog==255)
        {
            serverlogog-=1;
            serverlogob-=1;
        }
    }
}
#10
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);
#11
I'm looking into this plugin: https://forum.vc-mp.org/index.php?topic=9181.0
I'll publish the results within 90 days.
#12
Script Showroom / Re: BindKey Process System
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.
#13
Script Showroom / Re: Dipeos command
Mar 16, 2024, 08:45 AM
This script has no language formatting errors.
#14
Script Showroom / Re: BindKey Process System
Mar 16, 2024, 08:35 AM
I've optimized the script to make it easier to add methods, use only one timer, and be more efficient. Adapt the following code to your server.
function onScriptLoad()
{
    PlayerKeys<-{};
    ProcessKey<-{};
    ProcessKeyTime<-100; //This number sets the speed of the code
    ProcessKeyTimer<-null;
}
function onPlayerPart(player,reason)
{
    DeleteAllPlayerKeyToTable(player.ID);
}
function onKeyDown(player,key)
{
    AddPlayerKeyToTable(player.ID,key);
}
function onKeyUp(player,key)
{
    DeletePlayerKeyToTable(player.ID,key);
}

//Functions
function AddKeyToTable(key)
{
    ProcessKey.rawset(key,key);
}
function DeleteKeyToTable(key)
{
    if(ProcessKey.rawin(key)) ProcessKey.rawdelete(key);
}
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);
            }
            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(PlayerKeys.len()==0) DeleteProcessKeyTimer();
        }
    }
}
function DeleteAllPlayerKeyToTable(i)
{
    local plr=FindPlayer(i);
    if(plr)
    {
        if(PlayerKeys.rawin(plr.ID)) PlayerKeys.rawdelete(plr.ID);
    }
}
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++) onKeyDown(plr,arr[i]);
            }
        }
    }
}

test code: A simple fly code, I key up, K key down. The above code must be installed first.
function onScriptLoad()
{
    Key_J<-BindKey(true,0x4A,0,0);
    Key_L<-BindKey(true,0x4C,0,0);
    Key_I<-BindKey(true,0x49,0,0);
    Key_K<-BindKey(true,0x4B,0,0);
   
    AddKeyToTable(Key_I); //Adds the binding key to the table that is looped
    AddKeyToTable(Key_K);

    ProcessKeyTime=10;
}
function onKeyDown(player,key)
{
    if(key==Key_I) player.Pos.z+=1;
    if(key==Key_K) player.Pos.z-=1;
    if(key==Key_J) MessagePlayer("[#FFFF00]Key: J",player);
    if(key==Key_L) MessagePlayer("[#FFFF00]Key: L",player);
}
#15
Script Showroom / Re: BindKey Process System
Mar 11, 2024, 01:02 PM
If you don't want I and J to trigger loop execution, you can do so.
function onKeyDown(player,key) //Now only KL can trigger the loop execution
{
    if(key==Key_I)
{
Message("Key: I");
}
    if(key==Key_J)
{
Message("Key: J");
}
    if(key==Key_K)
{
Message("Key: K");
AddKeyTable(player.ID,key);
}
    if(key==Key_L)
{
Message("Key: L");
AddKeyTable(player.ID,key);
}
}