SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 01/04/2015, 11:45 AM   #1
AlterEGO
Big Clucker
 
AlterEGO's Avatar
 
Join Date: Jun 2014
Posts: 54
Reputation: 0
Default I can't seem to get it right...

Hi, I know Ive asked it before and all..,
But I can't seem to make it work. I don't know why, but it ain't working for me.
So i was wondering if anyone could help me and make me a /ame command code.
Simple, the command does a /me CMD which pops above the player for few seconds then disappear without any other players seeing it on thier string. Here is my /me code:

Code:
if(strcmp(cmd, "/me", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(gPlayerLogged[playerid] == 0)
	        {
	            SendClientMessage(playerid, COLOR_LIGHTRED, "   You havent logged in yet !");
	            return 1;
	        }
	        if(PlayerInfo[playerid][pMuted] == 1)
			{
				SendClientMessage(playerid, TEAM_CYAN_COLOR, "You cannot speak, you have been silenced");
				return 1;
			}
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[128];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_LIGHTRED, "USAGE: /me [action]");
				return 1;
			}
			if(PlayerInfo[playerid][pAdminDuty] == 1)
			{
   				format(string, sizeof(string), "* Admin %s", result);
			}
			if(PlayerInfo[playerid][pMaskuse] == 1 && PlayerInfo[playerid][pAdminDuty] == 0)
			{
			    format(string, sizeof(string), "* %s %s", PlayerInfo[playerid][pMaskName], result);
			}
			if(PlayerInfo[playerid][pAdminDuty] == 0 && PlayerInfo[playerid][pMaskuse] == 0)
			{
				format(string, sizeof(string), "* %s %s", sendername, result);
			}
			SetPlayerChatBubble(playerid, string, COLOR_CHAT1, 20.0, 2000);
			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] [/ME] %s: %s",d,m,y,h,mi,s,sendername,giveplayer, result);
			ActionLog(string);
		}
		return 1;
AlterEGO is offline   Reply With Quote
Old 01/04/2015, 11:54 AM   #2
Ritzy2K
High-roller
 
Ritzy2K's Avatar
 
Join Date: Jun 2014
Location: India
Posts: 1,547
Reputation: 170
Default Re: I can't seem to get it right...

Why not to use sscanf to make it simpler?

im on phone but if u want i can write this command with sscanf.

Edit: use zcmd too!
__________________
Ritzy2K is offline   Reply With Quote
Old 01/04/2015, 11:57 AM   #3
CalvinC
High-roller
 
CalvinC's Avatar
 
Join Date: Nov 2014
Location: Denmark
Posts: 1,830
Reputation: 114
Default Re: I can't seem to get it right...

Show the /ame code you're having problems with, not the /me code.
And i would recommend using ZCMD and SSCANF, which would make it hundred times easier and more efficient/faster.
__________________
[Tutorial] Custom Playerdamage system
Desert Eagle's dealing too much damage, you want one-hit sniper kills, or damage based on body parts? Check this out.
CalvinC is offline   Reply With Quote
Old 01/04/2015, 01:04 PM   #4
Ritzy2K
High-roller
 
Ritzy2K's Avatar
 
Join Date: Jun 2014
Location: India
Posts: 1,547
Reputation: 170
Default Re: I can't seem to get it right...

pawn Code:
CMD:me(playerid, params[])
{
    new action[50], fstr[50];
   if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, RED, "You Arent Logged In. Log In Before using the Command");
    if(sscanf(params, "s[50]", action)) return SendClientMessage(playerid, RED, "[USAGE]: /me [action]");
    if([playerid][pMuted] == 1) return SendClientMessage(playerid, RED, "You cant use this command while your muted.");
    if(strlen(action) < 1 || strlen(action) > 64) return SendClientMessage(playerid, RED, "Your action can only contain 1-64 characters.");
    format(fstr, sizeof(fstr), "%s %s...", GetName(playerid), action);
    SendClientMessageToAll(WHITE, fstr);
    return true;
}

sorry couldnt make it completely accurate to your command since im a newbie kinda..but it should help you.. and its simpler and easier

i
__________________
Ritzy2K is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 05:59 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.