Hello Friends Whasup? I am going to share Give heal Command With you guyz
What is in it? : It will able every friend to heal his friend for only 250$
Here is the code
else if ( cmd == "giveheal" )
{
if ( !text ) PrivMessage( player, "Use /giveheal <Nick/ID>" );
local plr = FindPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) PrivMessage( player, "Unknown Player.." );
else if ( plr.Health == 100 ) PrivMessage( player, " " + plr.Name + " Dont need to be healed" );
else if ( player.Cash < 250 ) PrivMessage( player, "You need $250 to heal " + plr.Name + "." );
else {
plr.Health = 100;
PrivMessage( plr, "Healed by " + player.Name + "." );
Message( " " + player.Name + " has healed " + plr.Name + "." );
player.Cash -= 250;
}
}
function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
tokenized = split(string, separator),
text = "";
if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}
function NumTok(string, separator)
{
local tokenized = split(string, separator);
return tokenized.len();
local s = split(string, separator);
return s.len();
}
Share, Enjoy
Updated :)
So, suppose you are going to use this in a DM server, a player is fighting with someone and his friend will heal him constantly. Better make it a command for admins and remove cash thing.
if ( cmd == "giveheal" )
{
if ( !text ) PrivMessage( player, "Use /giveheal <Nick/ID>" );
local plr = GetPlayer( GetTok( text, " ", 1 ) );
if ( !plr ) PrivMessage( player, "Unknown Player.." );
else if ( plr.Health == 100 ) PrivMessage( player, " " + plr.Name + " Dont need to be healed" );
else {
plr.Health = 100;
PrivMessage( plr, "Healed by " + player.Name + "." );
Message( " " + player.Name + " has healed " + plr.Name + "." );
}
}
function GetPlayer( plr )
{
if ( plr )
{
if ( IsNum( plr ) )
{
plr = FindPlayer( plr.tointeger() );
if ( plr ) return plr;
else return false;
}
else
{
plr = FindPlayer( plr );
if ( plr ) return plr;
else return false;
}
}
else return false;
}
function GetTok(string, separator, n, ...)
{
local m = vargv.len() > 0 ? vargv[0] : n,
tokenized = split(string, separator),
text = "";
if (n > tokenized.len() || n < 1) return null;
for (; n <= m; n++)
{
text += text == "" ? tokenized[n-1] : separator + tokenized[n-1];
}
return text;
}
i will add timer
Everyone can make it
so why you don't make?
I can make that, u can heal your friend by typing heal <name>, what's new in it?
its not for you its for newbies who don't know scripting Got it?
Then paste heal cmd, its better than give heal
HealTimer <- array(GetMaxPlayers(),false);
function onPlayerPart(player,reason)
{
HealTimer[player.ID] = false;
return 1;
}
function onPlayerCommand(player,cmd,text)
{
if (cmd) cmd = cmd.tolower();
local plr, veh = player.Vehicle;
if (text) plr = GetPlayer(text);
if (cmd == "giveheal")
{
if (!player.Spawned) PrivMessage(player,"You have to be spawned to use that command!");
else if (!text) PrivMessage(player,"Use: /"+cmd+" <Nick/ID>");
else if (!plr) PrivMessage(player,"This player doesn't exist!");
else if (plr.ID == player.ID) PrivMessage(player,"You can't heal yourself!");
else if (!plr.Spawned) PrivMessage(player,plr.Name+" hasn't spawned yet!");
else if (plr.Health == 100) PrivMessage(player,plr.Name+" Dont need to be healed!");
else if (player.Cash < 250) PrivMessage(player,"You need $250 to heal "+plr.Name+"!");
else if (GetDistance(Vector(player.Pos.x,player.Pos.y,player.Pos.z),Vector(plr.Pos.x,plr.Pos.y,plr.Pos.z) < 25)) PrivMessage(player,plr.Name+" is too far away!");
else if (HealTimer[player.ID]) PrivMessage(player,"You've used this command a while ago!");
else
{
plr.Health = 100;
player.Cash -= 250;
HealTimer[player.ID] = true;
NewTimer("HealTime",60000,1,player.ID);
PrivMessage(plr,"Healed by "+player.Name+".");
Message(player.Name+" has healed "+plr.Name+" for $250.");
}
}
else PrivMessage(player,"This command doesn't exist!");
return 1;
}
function HealTime(playerid)
{
local player = FindPlayer(playerid);
if (player) HealTimer[player.ID] = false;
}
function GetDistance(v1,v2) return sqrt((v2.x-v1.x)*(v2.x-v1.x) + (v2.y-v1.y)*(v2.y-v1.y) + (v2.z-v1.z)*(v2.z-v1.z));
function GetPlayer( plr )
{
if ( plr )
{
if ( IsNum( plr ) )
{
plr = FindPlayer( plr.tointeger() );
if ( plr ) return plr;
else return false;
}
else
{
plr = FindPlayer( plr );
if ( plr ) return plr;
else return false;
}
}
else return false;
}
With timer and GetDistance ;) but better create second function for all timers
Why on earth use a timer for resetting a cooldown?
Why not doing HealTimer[ player.ID ] = time();
and if ( ( time() - HealTimer[ player.ID ] ) < 60000 )
There's already a very decent healing snippet here (http://forum.vc-mp.org/index.php?topic=60.0). Why bother making another broke snippet and dare to share it :-\
Quote from: S.L.C on Aug 16, 2015, 11:31 AMThere's already a very decent healing snippet here (http://forum.vc-mp.org/index.php?topic=60.0). Why bother making another broke snippet and dare to share it :-\
leave him alone guys, atleast he is trying to be good
thanks Devil anyway lock