[Help - Easy] Making a command available ONLY when & during a timer is active
#1

I want to make a command that players can use when someone gets banned. For example, some dude gets banned, a timer gets started (RIPTimer) for 1 minute and players can do /rip, but only once and basically spam messages from everyone who uses /rip would appear on the screen with a static message. So, the point is that everyone can use this ONCE for the duration of the timer. But, for some reason I cannot script it right.

First I forward
Код:
forward RIPTimer(giveplayerid);
then add this to the enums
Код:
enum pInfo
{
    pRIP
}
Then I make a function that will change the player's pRIP status back to 0 when the timer is done

Код:
public RIPTimer(giveplayerid)
{
    PlayerInfo[giveplayerid][pRIP]==0;
}
Here's my command. I NEED HELP HERE:

Код:
CMD:rip(playerid,params[])
{
	new PlayerName[MAX_PLAYER_NAME], str[128];
	GetPlayerRPName(playerid, PlayerName, sizeof(PlayerName));
	if(/*Need to add here to check if the RIPTimer is active*/)
	{
	    if(PlayerInfo[playerid][pRIP]==0)
	    {
	        PlayerInfo[playerid][pRIP]==1;
	        format(str, 128, "[BS] {} Player %s has expressed their condolences for the banned player", );
	        SendClientMessageToAll(COLOR_DARKCORAL, str);
		}
	}
	else
  	{
  		SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}You can use this command once for a period of 1 minute after a player gets banned!");
    }
    return 1;
}
Since I'm the only one currently testing and developing the server I need a test command. This is to activate the timer to test the /rip command.


Код:
CMD:riptimer(playerid,params[])
{
    SetTimerEx("RIPTimer", 30000, 0, "d", i);
    return 1;
}
Reply
#2

Код:
new RipActive = 0;
Код:
if(RipActive == 1)
{
// Your function
}
Код:
CMD:riptimer(playerid,params[])
{
    SetTimerEx("RIPTimer", 30000, 0, "d", i);
    RipActive = 1;
    return 1;
}
Код:
public RIPTimer(giveplayerid)
{
    PlayerInfo[giveplayerid][pRIP]==0;
    RipActive = 0;
}
Reply
#3

Код:
CMD:rip(playerid,params[])
{
	new PlayerName[MAX_PLAYER_NAME], str[128];
	GetPlayerRPName(playerid, PlayerName, sizeof(PlayerName));
	if(PlayerInfo[playerid][pRIP]==0)
	    {
	        PlayerInfo[playerid][pRIP]=1;
	        format(str, 128, "[BS] {} Player %s has expressed their condolences for the banned player", );
	        SendClientMessageToAll(COLOR_DARKCORAL, str);
		}
	else
  	{
  		SendClientMessage(playerid, COLOR_DARKCORAL, "[BS] {AFAFAF}You can use this command once for a period of 1 minute after a player gets banned!");
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Flamehaze7
Посмотреть сообщение
Код:
new RipActive = 0;
Код:
if(RipActive == 1)
{
// Your function
}
Код:
CMD:riptimer(playerid,params[])
{
    SetTimerEx("RIPTimer", 30000, 0, "d", i);
    RipActive = 1;
    return 1;
}
Код:
public RIPTimer(giveplayerid)
{
    PlayerInfo[giveplayerid][pRIP]==0;
    RipActive = 0;
}
Thanks for the idea, I did it this way. Now i have another problem At the rip command when it prints out the message. I want it do be extremely distinctive from the other messages so u can scroll back and find a missing chat text or something easily.

Код:
new str[128];
format(str, sizeof(str), "[BS] {E82420} Player{E820CD} %s {E1E820}has {3E20E8}expressed {48E820}their {20E8E8}condolences {E8A220}for {E8207A}the {131414}banned {20E8AC}player", PlayerName);
SendClientMessageToAll(COLOR_DARKCORAL, str);
and I get :



It doesn't show the full message. If I change str[128] to str[256] It doesn't even show the message at all
Reply
#5

PHP код:
new str[128]; 
to
PHP код:
new str[173]; 
Reply
#6

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
PHP код:
new str[128]; 
to
PHP код:
new str[173]; 
Nope, as I said, changing the str length won't do anything, I need another way. When I do this and go in game and type the command nothing shows up, not even the timestamp, it's not even an empty string, it simply doesn't show
Reply
#7

Just remove some color tags or send it in a new line.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)