Help with making a timer for /ame
#1

Hello, and first i'd like to thank everyone who contributes to this, well here is my problem. in-game i do /ame (blah blah) and it says and it wont go away, im not the best at scripting so this is kinda new to me, How instead of having to do /ame off to turn it off i would like it to go away in 7 seconds

here is the code for the command,

Код:
CMD:ame(playerid, params[])
{
    new activewep = GetPVarInt(playerid, "activesling");
	new message[100], string[128];
	if(sscanf(params, "s[100]", message))
	{
		SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /ame [action]");
		SendClientMessageEx(playerid, COLOR_GRAD2, "NOTE: Set the action to OFF to remove the label.");
		return 1;
	}
	if(activewep > 0)
	{
	    SendClientMessageEx(playerid, COLOR_GRAD2, "  You have a weapon slung around your back, you can't use /ame.");
	    return 1;
	}
	if(strcmp(message, "off", true) == 0)
	{
	    SendClientMessageEx(playerid, COLOR_GRAD2, "  You have removed the description label.");

	    DestroyDynamic3DTextLabel(PlayerInfo[playerid][aMeID]);
	    PlayerInfo[playerid][aMeStatus] =0;
	    return 1;
	}
	if(strlen(message) > 100) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too long, please reduce the length.");
	if(strlen(message) < 3) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too short, please increase the length.");
	if(PlayerInfo[playerid][aMeStatus] == 0)
	{
	    PlayerInfo[playerid][aMeStatus] =1;

		format(string, sizeof(string), "* %s %s", GetPlayerNameEx(playerid), message);
		PlayerInfo[playerid][aMeID] = CreateDynamic3DTextLabel(string, COLOR_PURPLE, 0.0, 0.0, 0.0, 20.0, playerid);
		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		return 1;
	}
	else
	{
		format(string, sizeof(string), "* %s %s", GetPlayerNameEx(playerid), message);
		UpdateDynamic3DTextLabelText(PlayerInfo[playerid][aMeID], COLOR_PURPLE, string);
		ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		return 1;
	}
}
Reply
#2

Hello! You don't actaully need to use a text label to achieve this; You can use the default SetPlayerChatBubble option already provided by SA-MP.

Here's an edit of your code that *should* work, however I haven't actually tested it ingame.

Код:
CMD:ame(playerid, params[])
{
    new activewep = GetPVarInt(playerid, "activesling");
	new message[100], string[128];
	if(sscanf(params, "s[100]", message))
		return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /ame [action]");

	if(activewep > 0)
	    return SendClientMessageEx(playerid, COLOR_GRAD2, "  You have a weapon slung around your back, you can't use /ame.");

	if(strlen(message) > 100) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too long, please reduce the length.");
	if(strlen(message) < 3) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too short, please increase the length.");
	
	format(string, sizeof(string), "* %s *", message);
 	SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 7.0, 10000);
  	format(string, sizeof(string), "Annotated Message: %s", message);
   	SendClientMessageEx(playerid, COLOR_PURPLE, string);
   	return 1;
}
Kind Regards.
Reply
#3

Quote:
Originally Posted by Tessa
Посмотреть сообщение
Hello! You don't actaully need to use a text label to achieve this; You can use the default chatbubble option already provided by SA-MP.

Here's an edit of your code that *should* work, however I haven't actually tested it ingame.

Код:
CMD:ame(playerid, params[])
{
    new activewep = GetPVarInt(playerid, "activesling");
	new message[100], string[128];
	if(sscanf(params, "s[100]", message))
		return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /ame [action]");

	if(activewep > 0)
	    return SendClientMessageEx(playerid, COLOR_GRAD2, "  You have a weapon slung around your back, you can't use /ame.");

	if(strlen(message) > 100) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too long, please reduce the length.");
	if(strlen(message) < 3) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too short, please increase the length.");
	
	format(string, sizeof(string), "* %s *", message);
 	SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 7.0, 10000);
  	format(string, sizeof(string), "Annotated Message: %s", message);
   	SendClientMessageEx(playerid, COLOR_PURPLE, string);
   	return 1;
}
Kind Regards.
Thank you for the reply Tessa, I will try this right now, and get back to you ASAP!
Reply
#4

Hello, Tessa in game do you know how can i show the playername, I modified it alittle and it is at this now,

Код:
CMD:ame(playerid, params[])
{
    new activewep = GetPVarInt(playerid, "activesling");
	new message[100], string[128];
	if(sscanf(params, "s[100]", message))
		return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /ame [action]");

	if(activewep > 0)
	    return SendClientMessageEx(playerid, COLOR_GRAD2, "  You have a weapon slung around your back, you can't use /ame.");

	if(strlen(message) > 100) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too long, please reduce the length.");
	if(strlen(message) < 3) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too short, please increase the length.");

	format(string, sizeof(string), "--> %s", message);
 	SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 7.0, 10000);
  	format(string, sizeof(string), "--> %s", message);
   	SendClientMessageEx(playerid, COLOR_PURPLE, string);
   	return 1;
}
Reply
#5

Quote:
Originally Posted by NickMirra
Посмотреть сообщение
Hello, Tessa in game do you know how can i show the playername, I modified it alittle and it is at this now,

Код:
CMD:ame(playerid, params[])
{
    new activewep = GetPVarInt(playerid, "activesling");
	new message[100], string[128];
	if(sscanf(params, "s[100]", message))
		return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /ame [action]");

	if(activewep > 0)
	    return SendClientMessageEx(playerid, COLOR_GRAD2, "  You have a weapon slung around your back, you can't use /ame.");

	if(strlen(message) > 100) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too long, please reduce the length.");
	if(strlen(message) < 3) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too short, please increase the length.");

	format(string, sizeof(string), "--> %s", message);
 	SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 7.0, 10000);
  	format(string, sizeof(string), "--> %s", message);
   	SendClientMessageEx(playerid, COLOR_PURPLE, string);
   	return 1;
}
Hello, with showing the name, I assume its before the "-->"? If so, the following code should do the trick:

Код:
CMD:ame(playerid, params[])
{
    new activewep = GetPVarInt(playerid, "activesling");
	new message[100], string[128];
	if(sscanf(params, "s[100]", message))
		return SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /ame [action]");

	if(activewep > 0)
	    return SendClientMessageEx(playerid, COLOR_GRAD2, "  You have a weapon slung around your back, you can't use /ame.");

	if(strlen(message) > 100) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too long, please reduce the length.");
	if(strlen(message) < 3) return SendClientMessageEx(playerid, COLOR_GRAD2, "  The action is too short, please increase the length.");

	format(string, sizeof(string), "%s --> %s", pName(playerid), message);
 	SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 10.0, 7000);
  	format(string, sizeof(string), "%s --> %s", pName(playerid), message);
   	SendClientMessageEx(playerid, COLOR_PURPLE, string);
   	return 1;
}
I added another %s and I used pName(playerid) to get the name.
Now most likely, it's going to error that it doesn't know what pName is.. if you indeed get an error, you can place the following code anywhere in the script (Preferred somewhere at the bottom).

Also make sure you don't have a similar function inside your script already.

Код:
pName(playerid)
{
	new pname[24];
	GetPlayerName(playerid,pname,24);
	return pname;
}
Kind regards.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)