I am creating /fix cmd. If player moves his car, fixing cancel. What will the syntax for it.
I am also creating /vehkill cmd. How to get the vehicle from its ID. e.g. I have a car pcj-600 and it's id is 1. If player types /vehkill 1, the heath of the vehicle should be set to 0. How to get the vehicle from the ID e.g form ID 1.
Quote from: umar4911 on Nov 14, 2017, 11:15 AMI am also creating /vehkill cmd. How to get the vehicle from its ID. e.g. I have a car pcj-600 and it's id is 1. If player types /vehkill 1, the heath of the vehicle should be set to 0. How to get the vehicle from the ID e.g form ID 1.
link (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/FindVehicle)
FindVehicle( int_ID );
link to kill (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/Vehicle.Kill)
Quote from: zeus on Nov 14, 2017, 11:51 AMQuote from: umar4911 on Nov 14, 2017, 11:15 AMI am also creating /vehkill cmd. How to get the vehicle from its ID. e.g. I have a car pcj-600 and it's id is 1. If player types /vehkill 1, the heath of the vehicle should be set to 0. How to get the vehicle from the ID e.g form ID 1.
link (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/FindVehicle)
FindVehicle( int_ID );
link to kill (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/Vehicle.Kill)
Thank you. How to receive data from function used in Newtimer
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Timer_Functions
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/NewTimer
NewTimer( "CallingFunction", 1000, 1, "1st argument", "2nd argument" );
function CallingFunction( arg, arg1 )
{
print(arg);
print(arg1);
}
:edit:
Some examples
Example#1 (http://wiki.vc-mp.org/wiki/OnPlayerRequestSpawn)
Example#2 (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/Timer.Delete)
Quote from: zeus on Nov 15, 2017, 10:29 AMhttp://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Timer_Functions
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/NewTimer
NewTimer( "CallingFunction", 1000, 1, "1st argument", "2nd argument" );
function CallingFunction( arg, arg1 )
{
print(arg);
print(arg1);
}
:edit:
Some examples
Example#1 (http://wiki.vc-mp.org/wiki/OnPlayerRequestSpawn)
Example#2 (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/Timer.Delete)
not this
see the code
else if ( cmd == "fix" )
{
local veh = player.Vehicle;
if ( !veh ) MessagePlayer( "[#FFDD33]Usage Error:[#FFFFFF] You must be in a Vehicle.", player );
else if ( veh.Health == 1000 ) MessagePlayer( "[#FFDD33]Usage Error:[#FFFFFF] Your Vehicle is already fixed..", player );
else {
Announce( "~r~Fixing...", player , 0 );
NewTimer( "fixcheck", 500, 10, player.ID);
MessagePlayer( "[#FFDD33]Information:[#FFFFFF] Dont Move your car for 5 seconds", player );
if(!fixcheck(player, veh, lastX, lastY, lastZ, newX, newY, newZ)) MessagePlayer("[#FFDD33]Information:[#FFFFFF] Repairing cancellled", player);
else
{
Veh.Fix();
MessagePlayer( "[#FFDD33]Information:[#FFFFFF] Your Vehicle Has Been Fixed", player );
}
}
}
See this. Now the line
if(!fixcheck(player, veh, lastX, lastY, lastZ, newX, newY, newZ)) MessagePlayer("[#FFDD33]Information:[#FFFFFF] Repairing cancellled", player);
I want that if player moves car, reparing cancels
Quote from: umar4911 on Nov 15, 2017, 12:05 PMQuote from: zeus on Nov 15, 2017, 10:29 AMhttp://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions#Timer_Functions
http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/NewTimer
NewTimer( "CallingFunction", 1000, 1, "1st argument", "2nd argument" );
function CallingFunction( arg, arg1 )
{
print(arg);
print(arg1);
}
:edit:
Some examples
Example#1 (http://wiki.vc-mp.org/wiki/OnPlayerRequestSpawn)
Example#2 (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/Timer.Delete)
not this
see the code
else if ( cmd == "fix" )
{
local veh = player.Vehicle;
if ( !veh ) MessagePlayer( "[#FFDD33]Usage Error:[#FFFFFF] You must be in a Vehicle.", player );
else if ( veh.Health == 1000 ) MessagePlayer( "[#FFDD33]Usage Error:[#FFFFFF] Your Vehicle is already fixed..", player );
else {
Announce( "~r~Fixing...", player , 0 );
NewTimer( "fixcheck", 500, 10, player.ID);
MessagePlayer( "[#FFDD33]Information:[#FFFFFF] Dont Move your car for 5 seconds", player );
if(!fixcheck(player, veh, lastX, lastY, lastZ, newX, newY, newZ)) MessagePlayer("[#FFDD33]Information:[#FFFFFF] Repairing cancellled", player);
else
{
Veh.Fix();
MessagePlayer( "[#FFDD33]Information:[#FFFFFF] Your Vehicle Has Been Fixed", player );
}
}
}
See this. Now the line
if(!fixcheck(player, veh, lastX, lastY, lastZ, newX, newY, newZ)) MessagePlayer("[#FFDD33]Information:[#FFFFFF] Repairing cancellled", player);
I want that if player moves car, reparing cancels
Use the onPlayerMove function to do the workaround. Don't forget to verify if the player is in a vehicle.
Quote from: KuRiMi on Nov 15, 2017, 05:25 PMUse the onPlayerMove function to do the workaround. Don't forget to verify if the player is in a vehicle.
Not a better method consumes too much memory if there are 100 players online around the city and all of them are in vehicle and using /fix command.
Better to do it like this
if ( cmd == "fix" )
{
if ( !player.Vehicle ) MessagePlayer( "[#FFDD33]Usage Error:[#FFFFFF] You must be in a Vehicle.", player );
else if ( player.Vehicle.Health == 1000 ) MessagePlayer( "[#FFDD33]Usage Error:[#FFFFFF] Your Vehicle is already fixed..", player );
else
{
NewTimer( "VerifyVehAntiMove", 5000, 1, player.Pos.x, player.Pos.y, player.ID );
MessagePlayer( "[#FFDD33]Information:[#FFFFFF] Fixing in process, don't move your car for 5 seconds.", player );
}
}
function VerifyVehAntiMove( playerPosX, playerPosY, playerID )
{
local player = FindPlayer( playerID );
if ( !player ) return;
if ( !player.Vehicle )
{
MessagePlayer("[#FFDD33]Information:[#FFFFFF] Repairing cancellled, not in a vehicle.", player);
return;
}
if ( DistanceFromPoint( player.Pos.x, player.Pos.y, playerPosX, playerPosY ) > 2 )
{
MessagePlayer("[#FFDD33]Information:[#FFFFFF] Repairing cancellled, moving.", player);
return;
}
player.Vehicle.Fix();
MessagePlayer( "[#FFDD33]Information:[#FFFFFF] Your Vehicle Has Been Fixed", player );
}
Quote from: zeus on Nov 16, 2017, 08:14 AMQuote from: KuRiMi on Nov 15, 2017, 05:25 PMUse the onPlayerMove function to do the workaround. Don't forget to verify if the player is in a vehicle.
Not a better method consumes too much memory if there are 100 players online around the city and all of them are in vehicle and using /fix command.
Better to do it like this
if ( cmd == "fix" )
{
if ( !player.Vehicle ) MessagePlayer( "[#FFDD33]Usage Error:[#FFFFFF] You must be in a Vehicle.", player );
else if ( player.Vehicle.Health == 1000 ) MessagePlayer( "[#FFDD33]Usage Error:[#FFFFFF] Your Vehicle is already fixed..", player );
else
{
NewTimer( "VerifyVehAntiMove", 5000, 1, player.Pos.x, player.Pos.y, player.ID );
MessagePlayer( "[#FFDD33]Information:[#FFFFFF] Fixing in process, don't move your car for 5 seconds.", player );
}
}
function VerifyVehAntiMove( playerPosX, playerPosY, playerID )
{
local player = FindPlayer( playerID );
if ( !player ) return;
if ( !player.Vehicle )
{
MessagePlayer("[#FFDD33]Information:[#FFFFFF] Repairing cancellled, not in a vehicle.", player);
return;
}
if ( DistanceFromPoint( player.Pos.x, player.Pos.y, playerPosX, playerPosY ) > 2 )
{
MessagePlayer("[#FFDD33]Information:[#FFFFFF] Repairing cancellled, moving.", player);
return;
}
player.Vehicle.Fix();
MessagePlayer( "[#FFDD33]Information:[#FFFFFF] Your Vehicle Has Been Fixed", player );
}
Thank you