03.11.2010, 04:55
is i possible to be able to make a cuffing system that enables players to run but not sprint nor drive? as that is more Realistic then breaking handcuffs.
It's possible. You could check if their velocity on-foot was greater than a normal running speed and slow them down. And for the other, you could just make it to where they couldn't get in vehicles.
|
// This will print the velocity of the player
// Load this as a filterscript, go in-game and type /print
// Then run (without sprinting) to check the velocity
// Exit the game
// Look at the console for the results
// NOTE: You may want to run for a while so you can see the running results more than others
#include <a_samp>
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/print", true) == 0)
{
SetTimerEx("Timer", 1000, 1, "i", playerid);
return 1;
}
return 0;
}
forward Timer(playerid);
public Timer(playerid)
{
new Float:X, Float:Y, Float:Z;
GetPlayerVelocity(playerid, X, Y, Z);
print("X: %0.2f | Y: %0.2f | Z: %0.2f", X, Y, Z);
return 1;
}
Just make a quick script to print your velocity while running (not sprinting) and check what it is. You can then build off of there.
After you retrieve the normal X Y and Z velocity of normal running, you can check if the player is cuffed and running at a higher velocity than that and reduce their velocity with SetPlayerVelocity. |
// Line 11
if(!strcmp(cmdtext, "/print", true))
// Line 24
printf("X: %0.2f | Y: %0.2f | Z: %0.2f", X, Y, Z);
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if (Cuffed[playerid] == 1)
{
new string[128];
new Float:x, Float:y, Float:z;
format(string, sizeof(string), "you cant enter a vehicle with your cuffs on!");
SendClientMessage(playerid, 0xFFFFFFFF, string);
GetPlayerPos(playerid,x,y,z);
return SetPlayerPos(playerid,x,y,z+3);
}
return 1;
}