SA-MP Forums Archive
[Help - Easy] Making a command available ONLY when & during a timer is active - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help - Easy] Making a command available ONLY when & during a timer is active (/showthread.php?tid=630587)



[SOLVED] Making a command available ONLY when & during a timer is active - Sibuscus - 16.03.2017

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;
}



Re: [Help - Easy] Making a command available ONLY when & during a timer is active - Flamehaze7 - 16.03.2017

Код:
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;
}



Re: [Help - Easy] Making a command available ONLY when & during a timer is active - GeneralAref - 16.03.2017

Код:
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;
}



Re: [Help - Easy] Making a command available ONLY when & during a timer is active - Sibuscus - 16.03.2017

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


Re: [Help - Easy] Making a command available ONLY when & during a timer is active - Dayrion - 16.03.2017

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



Re: [Help - Easy] Making a command available ONLY when & during a timer is active - Sibuscus - 16.03.2017

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


Re: [Help - Easy] Making a command available ONLY when & during a timer is active - Toroi - 16.03.2017

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