sprunk machine
#1

Hey so i made this code for sprunk machine and it doesnt work as i want to
when i press f it takes money but doesnt heal player
and when i spam f it just takes money without waiting

Код:
	if(GetPlayerMoney(playerid) >= 1)
	{
		if(PRESSED(KEY_SECONDARY_ATTACK))
		{
			if(IsPlayerInRangeOfPoint(playerid, 1.0, 320.1455,1733.6205,997.6163))
			{
				new Float:HP;
                if(HP >= 101)
				SetPlayerHealth(playerid, HP+20);
				GetPlayerHealth(playerid, HP);
				GivePlayerMoney(playerid, -1);
				ApplyAnimation(playerid,"VENDING","VEND_Use",1.4,0 ,1,1,0,2500,1);
		 	}
		}
	}
hope any one can help me fix it thanks
Reply
#2

PHP код:
if(PRESSED(KEY_SECONDARY_ATTACK)){
    if(
GetPlayerMoney(playerid) >= 1){
        if(
IsPlayerInRangeOfPoint(playerid1.0320.1455,1733.6205,997.6163)){
            new 
Float:HP;
            
GetPlayerHealth(playeridHP);
            if(
HP 100.0){
                
HP += 20.0;
                if(
HP 100.0HP 100.0;
                
SetPlayerHealth(playeridHP);
                
GivePlayerMoney(playerid, -1);
                
ApplyAnimation(playerid,"VENDING","VEND_Use",1.4,,1,1,0,2500,1);
            }
        }
    }

Reply
#3

it works but not as i wanet too
when I spam F it fills the hp fast I want the player to wait 3-2 seconds before he can use it again
Reply
#4

PHP код:
new SprunkUse[MAX_PLAYERS];

if(
PRESSED(KEY_SECONDARY_ATTACK)){ 
    if(
GetPlayerMoney(playerid) >= 1){ 
        if(
IsPlayerInRangeOfPoint(playerid1.0320.1455,1733.6205,997.6163)){ 
            if(
GetTickCount()-SprunkUse[playerid] >= 2*1000){
                new 
Float:HP
                
GetPlayerHealth(playeridHP); 
                if(
HP 100.0){ 
                    
HP += 20.0
                    if(
HP 100.0HP 100.0
                    
SetPlayerHealth(playeridHP); 
                    
GivePlayerMoney(playerid, -1); 
                    
ApplyAnimation(playerid,"VENDING","VEND_Use",1.4,,1,1,0,2500,1);
                    
SprunkUse[playerid] = GetTickCount();
                } 
            }
        }
    } 

Reply
#5

thanks man works perfect dont really know how to rep but thanks

EDIT: u mind explaing what you have done because i didnt understand
with the if(GetTickCount()
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)