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

#1
UI.Sprite("test").hide();

local func= GetRemoteValueEx(GetRemoteValue("UI"),"Sprite")
CallRemoteFuncEx(func, GetRemoteValue("UI"), "test")
Quote from: PSL on Nov 20, 2024, 09:54 AMRemoteExec(CallRemoteFunc(GetRemoteValueEx(CallRemoteFunc(GetRemoteValueEx(GetRemoteValue("UI"),"Sprite"),"test"),"hide")),player);
error:remexec (remote): the index 'fetch' does not exist

This is very close to the answer, I can not find why the failure.
Hi PSL, this is close to answer. It can be fixed by using CallRemoteFuncEx. Then you can pass UI as environment object (this) of the function UI.Sprite. Otherwise you are calling UI.Sprite with roottable as environment object. Many variables coded inside function UI.Sprite will be tried to fetched from roottable instead of class UI.

So the complete correct answer may be:
local func= GetRemoteValueEx(GetRemoteValue("UI"),"Sprite");
local obj= CallRemoteFuncEx(func, GetRemoteValue("UI"), "test"); //environment object=GetRemoteValue("UI")
CallRemoteFuncEx(GetRemoteValueEx(obj, "hide"), obj); //again careful about environment object this = obj =UI.Sprite("test")
I hope this will do the work. Seeing that codes will get bigger there is metamethods available on GetRemoteValue. The interesting alternative:
GetRemoteValue("UI").Sprite("test").hide();
Above code will automatically expand itself.

Please tell me if these worked.
#2
Hi PSL,
I'm glad that you liked it. You are very much welcome.
#3
Quote from: PSL on Nov 01, 2024, 03:55 AMHi Habi. In addition to the client sends text to the server, and then the server compiles and executes the text, such a client-side call to the server is problematic. When the transmitted text needs variables, it is necessary to escape quotes, nesting quotes will cause problems, and the server will report an error that the variable does not exist.
In addition to sending executable text, there are other ways to call server-side functions directly, which has a similar effect.


Hi PSL, i have not yet made function to call server side functions from client. But here is Remote-Exec v1.1.2 in which client can call other client's functions and get back the return value.

Remote Exec v1.1.2

  • Fixed infinite loop in client side caused when passing array
        RemoteExec(SetRemoteValue("a",[100,200]),FindPlayer(0),true,print)
  • Fixed arrays returned from client having null values for half the indexes and original array starts after null.
  • RemoteExec now supports tables.
    Example: RemoteExec(SetRemoteValue("a", {b=3, c=4, d="okay", e=2.3, f=true, n=null, m={f=1}}), FindPlayer(0)).
    Supported data types are: null, bool, integer, float, string, Vector, EntityVector, Quaternion, array, and table.
    These data types can be transported between server and client. Tables will exclude keys or values that are functions or classes.
  • Types such as Player, Vehicle, Building, RayTrace, Colour, GUIElement, GUIButton, GUICanvas, GUICheckbox, GUIEditbox, GUILabel, GUIListbox, GUIMemobox, GUIProgressBar, GUIScrollbar, GUISprite, GUIWindow can also be returned from a client.
    When returned, they are in the form of a table consisting of key-value pairs.
  • Fixed GetRemoteValueEx returning "index not exist" when the object is an array.
  • Changed the environment object when compiling a string to the root table instead of the class Server, because it was executed inside Server::ServerData.
  • Added all functions: GetRemoteValue, GetRemoteValueEx, SetRemoteValue,SetRemoteValueEx,CallRemoteFunc,CallRemoteFuncEx client-side for helping one client call functions of other. The resultant objects are passed to the function 'PeerExec' which sends it to the target-client.
  • Fixed "Error getting squirrel object" when Boolean is returned.
  • Fixed setting variables when boolean to true/false instead of 0/1.

How to call client side function from another client?

There is this new function called PeerExec

Quote from: PSL on Oct 30, 2024, 09:18 AMHello habi, I want to call another player's client function directly through the player's client and return the value, how can I achieve this?

Suppose you have a function 'test' in clientside:
function test(a,b)
{

}
You are player with id 1 and want to call 'test' in player with id 0 and return value:
PeerExec( GetRemoteValue("test")(15,20), 0, function(result){
print( result );
} );
//15=a, 20=b. 0=player with id 0.
//execution continues but the function is stored and invoked when the result from client 0 arrives.

Documentation
PeerExec( [superblob], target-player-id, func )
[superblob] : One returned by functions like GetRemoteValue, SetRemoteValue, etc.
target-player-id : The ID of the player in which you want to execute the logic.
func : An optional function. If provided will be called with the result of logic you executed in the target-player's script.
For full documentation, see files inside.

Examples client-side
  • PeerExec( GetRemoteValue("Console").Print("Hello World"), 0 )
    Prints 'Hello World' in blue colour in client-0
  • PeerExec(GetRemoteValue("RayTrace")(Vector(-337.56, -525.145, 12.7615), Vector(-349.419, -537.796, 12.8069),15), 0, function(res){
    if(res.Collided){ //This is valid because the result is transported as a table with key-value pairs.
    print("Collided");
    print(format(\"Position of Collision:(%f,%f,%f) \", res.Position.X,res.Position.Y, res.Position.Z));
    if(res.Entity.Type==2)print("Collision with - building");
    }
    }

    Result: debuglog.txt
    MSG: Collided
    MSG: Position of Collision:(-343.119232,-531.075500,12.782783)
    MSG: Collision with - building

Debugging
Any errors are logged in debuglog.txt in %appdata%/VCMP/04beta folder

Downloads (mediafire)
           
You can get the source of this plugin also.

You can read the usage here online and Bytecode Documentation here also.
#4
Hi Megamind,
Quotenpcclient v1.8 beta 4 = API 1.8
v1.8 beta 3 = API 1.6
So you are running v1.8 beta 3 or before. But plugins (rpclib, actionlib,..) are newer. So  npcclient.exe version is different. Here is the latest version of npcclient as of now. Also i think name of server output in console in beta 4 and not before. So you was running an older version of npcclient.

Also npc shoots and bullet not coming is an issue with 0.4.7.1 fixed in beta 4.

Could you get a screenshot of failure read [SCRIPT] next time if it comes?
#5
Quote from: MEGAMIND on Nov 15, 2024, 05:49 PMbut there names are still visible ingame but not in browser how can i hide ingame?
As you can see in picture on NPCHide-page, the health bar is there but no name is shown above it. It is because the client does not know actual name of the players. Actual name of npcs were replaced by " " (space string). Also the F5 screen is pretty neat.
I think by default it hides npc from browser only. If you want your npc to look like those in picture, you can issue a plugin command
0x10001001, "NPCHIDE_SETVAL 0" //ref: wiki
Unfortunately this plugin has not imported squirrel. You can send plugin-commands easily using this.
#6
Omg you have 17 plugins loaded!. Try to remove some unnecessary ones and try-again. I remember having some problem when total plugins go above 16.

Edit: About calling server-side functions from npcscripts, i give you one example:
RFC(F("compilestring")("FindPlayer(1).Skin=0"))()
RFC(F("compilestring")("FindPlayer(1).SetWeapon(27,66)"))()
#7
Quote from: MEGAMIND on Nov 15, 2024, 12:16 PM@habi2 hi i was testing some local npc running in server at different points randomnly where  i thought how about to hide it so looked at https://npc-for-vcmp.sourceforge.io/wikiw/index.php/NPCHide even downloaded the plugin i faced this Plugin error >> LoadLibrary() 'plugins/npc.dll' failed: Code 126
Failed to load plugin: npc
Hi megamind, the name of the plugin associated for hiding npc in browser is npchide. For 64-bit, 64 is suffixed. Please verify that name of plugin in server.cfg is same as the name of dll in plugins directory.
#8
Quote from: MEGAMIND on Nov 14, 2024, 10:01 PMhey @habi2 sup man, ok so i was trying to give it a more like gta vc npc feeling but i saw in the plugin that only SendCommand("_npc_skin_request 211");
    SendCommand("_npc_weapon_request 24");
were available from npcscripts but what about if we want like anims or alot more can be asked like to send commands from npc side to server..
Hi Megamind, there is an RFC in npcscripts side also.
You can execute commands serverside. As you can read in link, npc.IsAdmin=true is required for this.

I will come up with examples later on.

It is nice to know people interacting with your chatgpt a.i.

Please read examples(under See Also)  in wiki like setting cash. There is also one about setting weapon. good luck.
#9
Hi Megamind,

Here is 64-bit version of plugin with RFC function fixed:
npc04rel64-windows.zip (170.53 KB)

I was writing 8 bytes in allocated memory of 4 bytes for integer. Now casted the 8 byte integer to 4 byte and write in the 4 bytes memory.
#10
Hi Megamind i was not well for two days and now recovering fast.
The mechanism of creating npc with skin was created when npc didn't die. Now it dies and gets skin of the class which in your case maybe lovefist. I will fix it in next update. But you can
SendCommand("_npc_skin_request 65");
to set npc skin anytime. The above code set it to 65, as we discussed before. OnNPCSpawn might be the right place.

About server crashing issue, it is the 64-bit version of windows (and perhaps linux too) that has bug when using RFC. I will correct it.
#11
Hi @MEGAMIND, i see your messages and will fix it one by one.
Quotenpc is dead how he gonna spawn back?, bcz i see a msg that i have spawned but not actully spawned, even though i get npc it says player not spawned
Use RequestSpawn to spawn the npc.when it is dead. It will spawn in the same class.
function OnPlayerDeath(playerid)
{
if(playerid==GetMyID())
              RequestSpawn();
}
About crashing of server (i hope it is server that is crashing), when you use RFC repetitiously there might be some bug which i will look now.
#12
I am very much happy you asked this question.

From server you can call npcscript functions like LookAtPlayer:
RFC(1,"LookAtPlayer")(player.ID);
//Let 1 be ID of npc


RFC is available with npc04 plugin.
For this to work you have to load 'LibRPC' plugin of npc while connecting:
ConnectNPC("[npc]mike, "your_npc_script.nut", false, "", "rpclib");
//false = no console, hostname="" means 127.0.0.1
If you're using ConnectNPCEx instead of ConnectNPC then use following format:
Quote(name, Pos, angle, skinId, weaponId, classId, script="", enableconsoleinput=false, host="127.0.0.1", plugins="", ...)

If you want to use SendCommand it is same:
//From serverside only:
RFC(1, "SendCommand")("goto "+playerid);
#13
Quote from: MEGAMIND on Nov 07, 2024, 12:26 PMhow do i set the skin to it
You can set the skin of npc when using ConnectNPCEx
ConnectNPCEx("[npc]robin", Vector(-377.935, -536.472, 17.2828), 0.0, 0);
//Angle 0.0, Skin=0, Weapon  not specified

Also you can from npcscripts:
SendCommand("_npc_skin_request 0"); //if you need skin 0

Also from server, if player=npc, then
player.Skin=5; //medic
#14
Hi Megamind

The npc doesn't get skin. The npc04 plugin has code inside it for setting skin. It sets skin if any npc sends a setskin command. And when needed, our npc do send such commands.
#15
Quoteso basically the game isnt skill-based anymore, it has slowly become luck-based in 007
Got it.