Recent posts

#21
Support / Re: onPlayerMove but in client...
Last post by [R3V]Kelvin - Oct 23, 2025, 03:49 PM
Quote from: (vG)DesTroYeR^ on Oct 23, 2025, 09:50 AM
Quote from: Xmair on Oct 22, 2025, 08:53 PMYou could use Script::ScriptProcess

this doesn't have the desired parameters
And you don't need any! All you gotta do is use your imagination. Just refer to the wiki for reference when coding: https://wiki.vc-mp.org/wiki/Scripting/Squirrel/Client_Functions

localPlayerPos     <- null;
lastLocalPlayerPos <- null;

function Script::ScriptLoad()
{
    ::localPlayerPos = ::World.FindLocalPlayer().Position; // By reference (auto updated)
    ::lastLocalPlayerPos = ::Vector(::localPlayerPos); // We need a copy, not a reference
}

function Script::ScriptProcess()
{
    // Because we made a copy these will effectively differ from each other
    if ((::localPlayerPos.X != ::lastLocalPlayerPos.X) ||
        (::localPlayerPos.Y != ::lastLocalPlayerPos.Y) ||
        (::localPlayerPos.Z != ::lastLocalPlayerPos.Z))
    {
        ::OnLocalPlayerMove();
        ::lastLocalPlayerPos = ::Vector(::localPlayerPos);
    }
}

// -----------------------------------------------------------------------------

// No need for parameters at all! Just make use of the globals we already defined
function OnLocalPlayerMove()
{
    Console.Print("lastPos: (" + lastLocalPlayerPos.X + ", " + lastLocalPlayerPos.Y + ", " + lastLocalPlayerPos.Z +
        ")\t|\tnewPos: (" + localPlayerPos.X + ", " + localPlayerPos.Y + ", " + localPlayerPos.Z + ")");
}
#22
Script Showroom / How to detect a falling or jum...
Last post by (vG)DesTroYeR^ - Oct 23, 2025, 02:54 PM
----------> JUMP DETECTION <----------

function IsJumping(p) {
if(p.Action == 41) return 1; // (true)
else return 0; // (false)
}

----------> JUMP EXAMPLE CODE USAGE <----------

function onPlayerMove(player, lastX, lastY, lastZ, newX, newY, newZ){
if(IsJumping(player)){
player.Speed.z += 1;   // E---X---A---M---P---L---E
}
}


_________________________________________


----------> FALL DETECTION <----------

function IsFalling(p, Znew, Zlast) {
if(IsJumping(p)) return false;
if(Znew == Zlast) return false; // rarely happens if the player is continually moving, since you can barely find a straightforward surface so Z positions are almost always dynamic
local newZlower = (Znew < Zlast ? true : false);
if(newZlower) {
if(Zlast - Znew < 0.15) return false; // Not Falling (e.g, 11.3 - 11.2 = 0.1 is not a fall)
else return true; // > 0.15 is a fall (Approximate numbers - I didn't really calculate it precisely)
}
else {return false;} // Znew is bigger -> so climbing or going up somehow
}

----------> FALLING EXAMPLE CODE USAGE <----------
function onPlayerMove(player, lastX, lastY, lastZ, newX, newY, newZ){
if(IsFalling(player, newZ, lastZ)) player.Immunity = 32; // E---X---A---M---P---L---E
}


Lastly, what you have to do (The code's user) is to make sure about the value (0.15) accuracy by testing it out in ur server, so I will adjust it here accordingly, or I might test it later and find out the precise value.
#23
----------> JUMP DETECTION <----------

function IsJumping(p) {
if(p.Action == 41) return 1; // (true)
else return 0; // (false)
}

----------> JUMP EXAMPLE CODE USAGE <----------

function onPlayerMove(player, lastX, lastY, lastZ, newX, newY, newZ){
if(IsJumping(player)){
player.Speed.z += 1;   // E---X---A---M---P---L---E
}
}


_________________________________________


----------> FALL DETECTION <----------

function IsFalling(p, Znew, Zlast) {
if(IsJumping(p)) return false;
if(Znew == Zlast) return false; // rarely happens if the player is continually moving, since you can barely find a straightforward surface so Z positions are almost always dynamic
local newZlower = (Znew < Zlast ? true : false);
if(newZlower) {
if(Zlast - Znew < 0.15) return false; // Not Falling (e.g, 11.3 - 11.2 = 0.1 is not a fall)
else return true; // > 0.15 is a fall (Approximate numbers - I didn't really calculate it precisely)
}
else {return false;} // Znew is bigger -> so climbing or going up somehow
}

----------> FALLING EXAMPLE CODE USAGE <----------
function onPlayerMove(player, lastX, lastY, lastZ, newX, newY, newZ){
if(IsFalling(player, newZ, lastZ)) player.Immunity = 32; // E---X---A---M---P---L---E
}


Lastly, what you have to do (The code's user) is to make sure about the value (0.15) accuracy by testing it out in ur server, so I will adjust it here accordingly, or I might test it later and find out the precise value.
#24
Support / Re: onPlayerMove but in client...
Last post by (vG)DesTroYeR^ - Oct 23, 2025, 09:50 AM
Quote from: Xmair on Oct 22, 2025, 08:53 PMYou could use Script::ScriptProcess

this doesn't have the desired parameters, I am already tracking player's position via Server::ServerData(stream); function, I guess that if there's a function like on player move would be precise
#25
General Discussion / Win a Prize Worth Up to $100,0...
Last post by Pavonis - Oct 23, 2025, 05:30 AM
iPhone 17, gaming laptops, gift cards, crypto & more!
Join now: https://telegra.ph/Get-a-gift-worth-up-to-10000077-10-23-1478
#26
General Discussion / Win a Prize Worth Up to $100,0...
Last post by Pavonis - Oct 23, 2025, 05:29 AM
iPhone 17, gaming laptops, gift cards, crypto & more!
Join now: https://telegra.ph/Get-a-gift-worth-up-to-10000077-10-23-1114
#27
Support / Re: onPlayerMove but in client...
Last post by Xmair - Oct 22, 2025, 08:53 PM
You could use Script::ScriptProcess
#28
Client Scripting / Re: Client script for my serve...
Last post by (vG)DesTroYeR^ - Oct 22, 2025, 08:06 PM
man for fuck's sake - stop using chatgpt
you are a newbie and i know u well, that script isnt even logical and seems to be faulty (chatgpt written)

go learn scripting instead of braging about gpt shithole codes
#29
Support / onPlayerMove but in client sid...
Last post by (vG)DesTroYeR^ - Oct 22, 2025, 07:09 PM
My friend @gamingpro told me that there's a function in client side written like this:
function Player::PlayerMove(oldpos, newpos){
}

But I am not sure of this, can someone tell me if there's a function like this in client side? Sending high rate timers to client side frequently is laggy -> not only is it lagging for the sprite angle degrees im sending but is also cpu-bound of the panel.

I am now using local player = World.findlocalplayer(); // player.Position vector ---  but it needs more precision to get rid of lag, thats why im searching for a function like playermove in server side.

I basically want it works same as Player's default tag name that incessantly follows him precisely
#30
Support / Re: Client side urgent help ne...
Last post by (vG)DesTroYeR^ - Oct 22, 2025, 11:50 AM
Quote from: vitovc on Oct 21, 2025, 03:44 PMthere is no clientside player.Angle but you can 1) get it from server (with lag) with Stream function 2) or you can guess player's camera angle (it almost same as player.Angle when player is not looking back)

get_angle <- function(x, y, x2, y2){
  return ::atan2(y2 - y, x2 - x);
}
get_player_angle <- function(){
  local screen_size = ::GUI.GetScreenSize();
  local cam_from = ::GUI.ScreenPosToWorld(::Vector(screen_size.X * 0.5, screen_size.Y * 0.5, -1));
  local cam_to = ::GUI.ScreenPosToWorld(::Vector(screen_size.X * 0.5, screen_size.Y * 0.5, 1));
  return ::get_angle(cam_from.X, cam_from.Y, cam_to.X, cam_to.Y);
}
untested, I took code from Get player Camera zoom
local angle = ::get_player_angle();also maybe you will need to add some offset to result of angle to make it similar as serverside angle, to do it correctly use
normalize_angle <- function (a){
  return ::atan2(::sin(a), ::cos(a));
}

::normalize_angle(angle + 1.57079);

i was trying to develop an MVP Trophy tag above player's name tag, it keeps following him as long as he moves, i firstly had some issues regarding angle
but i took GetAngleFromDeg() function from forums and from the server side(Angles there in radians, -3.14 to 3.14) I sent to client side and did some offset according to degree angle, it is now good. But i wish if there were a ready to use angle index.
- ty for help thats useful