SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/06/2019, 04:35 AM   #1
waheed
Little Clucker
 
Join Date: Sep 2018
Posts: 1
Reputation: 0
Default How to make /td cmd need help!

i made this script and i am getting problem while ending/closing this timer it work all good but when current hp becomes equal to required hp it do not stop i think there is a mistake help me out pls...

rep++;


Code:
CMD:td(playerid, params[])
{
	new amount;
	if(sscanf(params, "d", amount)) return SendClientMessage(playerid, -1, "* Usage: /td [Amount]");
	if(Player[playerid][OnDose] == 1) return SendClientMessage(playerid, -1, "* You are already on dose can not take more drug right now.");
	if(Player[playerid][Drug] < amount || amount < 0) return SendClientMessage(playerid, -1, "* You do not have that much drugs.");
	if(amount > 5 ) return SendClientMessage(playerid, -1, "* You can die caz of over dose");
	if(amount == 0 || amount < 0 ) return 1;
	amount = amount * 10;
	new Float:hp;
	GetPlayerHealth(playerid, hp);
	new msg[100];
	format(msg, sizeof(msg), "* Your hp is: %f ", hp);
	SendClientMessage(playerid, -1, msg);

	if(hp == 100 || hp > 100) return SendClientMessage(playerid, -1, "* You already have full HP.");

	hp = hp + float(amount);
	
	Player[playerid][OnDose] = 1;
	amount = amount / 10;
	Player[playerid][Drug] = Player[playerid][Drug] - amount;
	
	format(msg, sizeof(msg), "* Your hp should be: %f ", hp);
	SendClientMessage(playerid, -1, msg);

	Player[playerid][DrugTimer] = SetTimerEx("drugHealthIncrease", 1000, true, "i f", playerid, hp);

	return 1;
}

//------------//
public drugHealthIncrease(playerid, hp)
{
	new Float:hpp;
	new msg[100];
	format(msg, sizeof(msg), "* Value of hp in func. : %f ", hp);
    SendClientMessage(playerid, -1, msg);
	GetPlayerHealth(playerid, hpp);
	format(msg, sizeof(msg), "* Value of hpp in func. : %f ", hpp);
    SendClientMessage(playerid, -1, msg);

	if(hp <= hpp)
	{
        KillTimer( Player[playerid][DrugTimer] );
        
        Player[playerid][OnDose] =0;
        format(msg, sizeof(msg), "* Your health has set to %f ", hpp);
        SendClientMessage(playerid, -1, msg);
        
        return 1;
	}else{
	    SendClientMessage(playerid, -1, "Falied to stop timer. and enter if statment");
	}
	
	SetPlayerHealth(playerid, (hpp + 5.00) );
	
	return 1;
}
waheed is offline   Reply With Quote
Old 17/06/2019, 07:28 AM   #2
SiNaGaMeR
Big Clucker
 
Join Date: Feb 2018
Location: Germany
Posts: 64
Reputation: 1
Default Re: How to make /td cmd need help!

PHP Code:
    if(hp <= hpp)
    {
        
KillTimerPlayer[playerid][DrugTimer] );
        
        
Player[playerid][OnDose] =0;
        
format(msgsizeof(msg), "* Your health has set to %f "hpp);
        
SendClientMessage(playerid, -1msg);
        
        
//return 1;// Remove this line or disable it!
    
}else{
        
SendClientMessage(playerid, -1"Falied to stop timer. and enter if statment");
    }
    
    
SetPlayerHealth(playerid, (hpp 5.00) );
    
    return 
1;

Maybe with disabling return that I said your code will be fixed.
SiNaGaMeR is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make ban,and unban cmd for offline player,and how to make /fakeban cmd PowerF Scripting Help 3 11/01/2015 09:31 AM
How to make /lockserver CMD + Audio CMD to make music for all players D3vin Scripting Help 2 19/04/2014 04:09 PM
Can someone make tutorial how to make vehicle tune saving system ? barts Scripting Help 3 09/01/2014 11:40 AM
How to make Admins Levels and how to make gates system and more Loranzo_De_Andreas Scripting Help 2 22/03/2013 11:56 AM
Noob question: how to make on-foot underwater spawn make player stick to ocean floor? kaisersouse Scripting Help 5 11/07/2012 02:30 PM


All times are GMT. The time now is 04:42 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.