SA-MP Forums Archive
How to make a /me and /Do - 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: How to make a /me and /Do (/showthread.php?tid=502976)



How to make a /me and /Do - JoanB - 27.03.2014

Hey guys so i am creating a costume script from Blank RP and i would like to ask how could i do a /me command so like /me then it says "name" What he said in /me
and /do what he typed #name"


Re: How to make a /me and /Do - Flake. - 27.03.2014

Theres 100000 tutorials on how to do it if you just search...


However heres my /do and /me

pawn Код:
CMD:do(playerid, params[])
{
    new
        result[ 128 ],
        string[ 128 ]
    ;
    if(sscanf(params, "s[128]", result)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: {FFFFFF}/do [action]");
    format(string, sizeof(string), "* %s (( %s ))", result, RPName(playerid));
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    printf("%s", string);
    return 1;
}

CMD:me(playerid, params[])
{
    new
        result[ 128 ],
        string[ 128 ]
    ;
    if(sscanf(params, "s[128]", result)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: {FFFFFF}/do [action]");
    format(string, sizeof(string), "* %s %s", RPName(playerid), result);
    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    printf("%s", string);
    return 1;
}



Re: How to make a /me and /Do - ChristianIvann09 - 27.03.2014

Very easy and simple mate

Код:
CMD:me(playerid, params[])
{
	if(CheckGMX(playerid)) return 1;
	if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [action]");
	new string[128];
	format(string, sizeof(string), "* %s %s", GetPlayerNameEx(playerid), params);
	SetPlayerChatBubble(playerid,string,COLOR_PURPLE,60.0,5000);
	ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
	    	return 1;
    }
	return 1;
}

CMD:do(playerid, params[])
{
	if(CheckGMX(playerid)) return 1;
	if(gPlayerLogged[playerid] == 0)
	{
		SendClientMessage(playerid, COLOR_GREY, "You're not logged in.");
		return 1;
	}
	if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /do [action]");
	else if(strlen(params) >= 100) return SendClientMessage(playerid, COLOR_GREY, "The specified message must not be longer than 99 characters in length.");
	new string[128];
	format(string, sizeof(string), "* %s (( %s ))", params, GetPlayerNameEx(playerid));
	SetPlayerChatBubble(playerid,string,COLOR_PURPLE,60.0,5000);
	ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    }
	return 1;
}



Re: How to make a /me and /Do - AhmedMohamed - 27.03.2014

and use that with any of these codes above:
pawn Код:
ProxDetector(Float: f_Radius, playerid, string[],col1,col2,col3,col4,col5)
{
    new
        Float: f_playerPos[3];

    GetPlayerPos(playerid, f_playerPos[0], f_playerPos[1], f_playerPos[2]);

    foreach(Player, i) {
        if((InsideShamal[playerid] == GetPlayerVehicleID(i) && GetPlayerState(i) == 2) || (InsideShamal[i] == GetPlayerVehicleID(playerid) && GetPlayerState(playerid) == 2) || (InsideShamal[playerid] != INVALID_VEHICLE_ID && InsideShamal[playerid] == InsideShamal[i])) {
            SendClientMessage(i, col1, string);
        }
        else if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid)) {
            if(IsPlayerInRangeOfPoint(i, f_Radius / 16, f_playerPos[0], f_playerPos[1], f_playerPos[2])) {
                SendClientMessage(i, col1, string);
            }
            else if(IsPlayerInRangeOfPoint(i, f_Radius / 8, f_playerPos[0], f_playerPos[1], f_playerPos[2])) {
                SendClientMessage(i, col2, string);
            }
            else if(IsPlayerInRangeOfPoint(i, f_Radius / 4, f_playerPos[0], f_playerPos[1], f_playerPos[2])) {
                SendClientMessage(i, col3, string);
            }
            else if(IsPlayerInRangeOfPoint(i, f_Radius / 2, f_playerPos[0], f_playerPos[1], f_playerPos[2])) {
                SendClientMessage(i, col4, string);
            }
            else if(IsPlayerInRangeOfPoint(i, f_Radius, f_playerPos[0], f_playerPos[1], f_playerPos[2])) {
                SendClientMessage(i, col5, string);
            }
        }
    }
    return 1;
}