Quote from: (vG)DesTroYeR^ on Oct 23, 2025, 09:50 AMAnd 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_FunctionsQuote from: Xmair on Oct 22, 2025, 08:53 PMYou could use Script::ScriptProcess
this doesn't have the desired parameters
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 + ")");
}
function IsJumping(p) {
if(p.Action == 41) return 1; // (true)
else return 0; // (false)
}
function onPlayerMove(player, lastX, lastY, lastZ, newX, newY, newZ){
if(IsJumping(player)){
player.Speed.z += 1; // E---X---A---M---P---L---E
}
}
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
}
function onPlayerMove(player, lastX, lastY, lastZ, newX, newY, newZ){
if(IsFalling(player, newZ, lastZ)) player.Immunity = 32; // E---X---A---M---P---L---E
}
function IsJumping(p) {
if(p.Action == 41) return 1; // (true)
else return 0; // (false)
}
function onPlayerMove(player, lastX, lastY, lastZ, newX, newY, newZ){
if(IsJumping(player)){
player.Speed.z += 1; // E---X---A---M---P---L---E
}
}
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
}
function onPlayerMove(player, lastX, lastY, lastZ, newX, newY, newZ){
if(IsFalling(player, newZ, lastZ)) player.Immunity = 32; // E---X---A---M---P---L---E
}
Quote from: Xmair on Oct 22, 2025, 08:53 PMYou could use Script::ScriptProcess
function Player::PlayerMove(oldpos, newpos){
}
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){untested, I took code from Get player Camera zoom
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);
}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 usenormalize_angle <- function (a){
return ::atan2(::sin(a), ::cos(a));
}
::normalize_angle(angle + 1.57079);