I need help with a command.
#1

Hi, I'm going to be short about it beacuse i'm short on time at the moment.
I need to make a command I scripted to be able to do after 30 seconds.
And the player need to wait 30 seconds before doing it. so here is the currect CMD:
Код:
}
	    if(strcmp(cmd,"/getup",true)==0)
	    {
	    if(IsPlayerConnected(playerid))
	    {
	        if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
			{
				SendClientMessage(playerid, COLOR_WHITE, "You need to wait 30 seconds before getting up.");
				ClearAnimations(playerid);
       			animation[playerid] = 0;
       			TogglePlayerControllable(playerid, 1);
       			format(string, sizeof(string), "* %s stumbles back up.", sendername);
      			ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
	        	new y, m, d;
				new h,mi,s;
				getdate(y,m,d);
				gettime(h,mi,s);
				format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /getup",d,m,y,h,mi,s,sendername);
				CommandLog(string);
	        	if(UsingSmokeAnim[playerid] == 1)
	            {
	                UsingSmokeAnim[playerid] = 0;
	            }
			}
			else
			{
			    SendClientMessage(playerid, COLOR_LIGHTRED, "You must be on foot to use this command");
			}
	    }
	    return 1;
Thanks in advance, I just need you guys to make this command on a timer, like the player need to wait 30 seconds.
Reply
#2

Hello!

You could work with gettime().
Is that what you want?
PHP код:
new lastTime[MAX_PLAYERS]; //at the top
if(!strcmp(cmd,"/getup",true))
{
    if(
IsPlayerConnected(playerid))
    {
        if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            if(
gettime() < lastTime[playerid])return SendClientMessage(playeridCOLOR_WHITE"You need to wait 30 seconds before getting up.");
            
lastTime[playerid] = gettime() + 30;
             
ClearAnimations(playerid);
               
animation[playerid] = 0;
               
TogglePlayerControllable(playerid1);
              
format(stringsizeof(string), "* %s stumbles back up."sendername);
              
ProxDetector(30.0playeridstringCOLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
            new 
ymd;
            new 
h,mi,s;
            
getdate(y,m,d);
            
gettime(h,mi,s);
            
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /getup",d,m,y,h,mi,s,sendername);
            
CommandLog(string);
              if(
UsingSmokeAnim[playerid] == 1)
             {
                   
UsingSmokeAnim[playerid] = 0;
              }
              return 
1;
        }
        return 
SendClientMessage(playeridCOLOR_LIGHTRED"You must be on foot to use this command");
    }
    return 
1;

Mencent
Reply
#3

Pawn Complier didn't respond after Ive inputted your command
Reply
#4

Show me how you have inserted it.

Mencent

Sorry for my bad english.
Reply
#5

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Show me how you have inserted it.

Mencent

Sorry for my bad english.
Exactly how to gave me the code.
Reply
#6

Quote:
Originally Posted by AlterEGO
Посмотреть сообщение
Exactly how to gave me the code.
Undefined symbol - gettime
Reply
#7

Here you go, propably the easiest way to do it.

PHP код:
// Put this line somewhere at the top of your script:
new canGetUp[MAX_PLAYERS];
forward resetGetUp(playerid);

// Put this under onplayerconnect
canGetUp[playerid] = 1;

// Your command
}
        if(
strcmp(cmd,"/getup",true)==0)
        {
        if(
IsPlayerConnected(playerid))
        {
            if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
            {
                if(
canGetUp[playerid] == 0) return SendClientMessage(playeridCOLOR_WHITE"You need to wait 30 seconds before getting up.");
                
// The timer set to 30 seconds to reset the variable
                
SetTimerEx("resetGetUp"30000false"i"playerid);
                
ClearAnimations(playerid);
                   
animation[playerid] = 0;
                   
TogglePlayerControllable(playerid1);
                   
format(stringsizeof(string), "* %s stumbles back up."sendername);
                  
ProxDetector(30.0playeridstringCOLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                new 
ymd;
                new 
h,mi,s;
                
getdate(y,m,d);
                
gettime(h,mi,s);
                
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /getup",d,m,y,h,mi,s,sendername);
                
CommandLog(string);
                if(
UsingSmokeAnim[playerid] == 1)
                {
                    
UsingSmokeAnim[playerid] = 0;
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_LIGHTRED"You must be on foot to use this command");
            }
        }
        return 
1;
        
// Put this somewhere too
public resetGetUp(playerid)
{
    
canGetUp[playerid] = 1;
    
SendClientMessage(playeridCOLOR_WHITE"You can now get up again."); // Remove this if you don't want it
    
return 1;

Reply
#8

Quote:
Originally Posted by Sellize
Посмотреть сообщение
Here you go, propably the easiest way to do it.

PHP код:
// Put this line somewhere at the top of your script:
new canGetUp[MAX_PLAYERS];
forward resetGetUp(playerid);
// Put this under onplayerconnect
canGetUp[playerid] = 1;
// Your command
}
        if(
strcmp(cmd,"/getup",true)==0)
        {
        if(
IsPlayerConnected(playerid))
        {
            if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
            {
                if(
canGetUp[playerid] == 0) return SendClientMessage(playeridCOLOR_WHITE"You need to wait 30 seconds before getting up.");
                
// The timer set to 30 seconds to reset the variable
                
SetTimerEx("resetGetUp"30000false"i"playerid);
                
ClearAnimations(playerid);
                   
animation[playerid] = 0;
                   
TogglePlayerControllable(playerid1);
                   
format(stringsizeof(string), "* %s stumbles back up."sendername);
                  
ProxDetector(30.0playeridstringCOLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                new 
ymd;
                new 
h,mi,s;
                
getdate(y,m,d);
                
gettime(h,mi,s);
                
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /getup",d,m,y,h,mi,s,sendername);
                
CommandLog(string);
                if(
UsingSmokeAnim[playerid] == 1)
                {
                    
UsingSmokeAnim[playerid] = 0;
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_LIGHTRED"You must be on foot to use this command");
            }
        }
        return 
1;
        
// Put this somewhere too
public resetGetUp(playerid)
{
    
canGetUp[playerid] = 1;
    
SendClientMessage(playeridCOLOR_WHITE"You can now get up again."); // Remove this if you don't want it
    
return 1;

This time, it's complied, but It's doesn't works IG, I can do the command whenever I want, And there no 30 seconds cooldown, All I want is, the player need to wait 30 seconds before doing this CMD..
Reply
#9

Forgot something, now it works

PHP код:
// Put this line somewhere at the top of your script:
new canGetUp[MAX_PLAYERS];
forward resetGetUp(playerid);

// Put this under onplayerconnect
canGetUp[playerid] = 1;

// Your command
}
        if(
strcmp(cmd,"/getup",true)==0)
        {
        if(
IsPlayerConnected(playerid))
        {
            if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
            {
                if(
canGetUp[playerid] == 0) return SendClientMessage(playeridCOLOR_WHITE"You need to wait 30 seconds before getting up.");
                
// The timer set to 30 seconds to reset the variable
                
SetTimerEx("resetGetUp"30000false"i"playerid);
                
// Setting the var to 0
                
canGetUp[playerid] = 0;
                
ClearAnimations(playerid);
                   
animation[playerid] = 0;
                   
TogglePlayerControllable(playerid1);
                   
format(stringsizeof(string), "* %s stumbles back up."sendername);
                  
ProxDetector(30.0playeridstringCOLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                new 
ymd;
                new 
h,mi,s;
                
getdate(y,m,d);
                
gettime(h,mi,s);
                
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /getup",d,m,y,h,mi,s,sendername);
                
CommandLog(string);
                if(
UsingSmokeAnim[playerid] == 1)
                {
                    
UsingSmokeAnim[playerid] = 0;
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_LIGHTRED"You must be on foot to use this command");
            }
        }
        return 
1;

// Put this somewhere too
public resetGetUp(playerid)
{
    
canGetUp[playerid] = 1;
    
SendClientMessage(playeridCOLOR_WHITE"You can now get up again."); // Remove this if you don't want it
    
return 1;

Reply
#10

Ok, nice!

Mencent
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)