SA-MP Forums Archive
Any idea ? - 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: Any idea ? (/showthread.php?tid=588945)



Any idea ? - saffierr - 13.09.2015

Any idea guys, how to script cmds such as /me /do /w(hisper)...

Any help is welcome, ((tuts are welcome either))


Re: Any idea ? - JasonSchneider - 13.09.2015

Sorry I havn't a time to show the tutorial but anyway here.

Код:
CMD:me(playerid, params[])
{
	new string[128];
	if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /me [action]");
	{
	format(string, sizeof(string), "* %s %s", RPN(playerid), params);
	}
	else
	{
	format(string, sizeof(string), "* %s %s", PlayerInfo[playerid][aMask], params);
	}
 	SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	return 1;
}
Код:
CMD:do(playerid, params[])
{
	new string[128];
	if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /me [action]");

	{
	format(string, sizeof(string), "* %s (( %s ))", params, RPN(playerid));
	}
	else
	{
	format(string, sizeof(string), "* %s (( %s ))", params, PlayerInfo[playerid][aMask]);
	}
	SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
	return 1;
}



AW: Any idea ? - Kaliber - 13.09.2015

It's just an easy function:

PHP код:
stock SendRangeMessage(playerid,color,const text[],Float:range)
{
    new 
Float:x,Float:y,Float:z;
    
GetPlayerPos(playerid,x,y,z);
    for(new 
i=GetPlayerPoolSize()+1; --i!=-1;)
    {
        if(!
IsPlayerConnected(i) || IsPlayerNPC(i) || !IsPlayerInRangeOfPoint(i,range,x,y,z)) continue;
        
SendClientMessage(i,color,text);
    }
    return 
1;
}
//Usage for /me:
CMD:me(playerid,params[])
{
    if(
isnull(params)) return SendClientMessage(playerid,-1,"Type: /me [Text]");
    new 
string[145];
    
GetPlayerName(playerid,string,MAX_PLAYER_NAME);
    
format(string,sizeof(string),"* %s %s",string,params);
    
SendRangeMessage(playerid,purple,string,25.0); //Range 25 feet...and color purple
    
return 1;

Same thing for whisper or sth else..just change the distance


Re: Any idea ? - saffierr - 13.09.2015

I've tested it and it works fine, although I've got a few questions.

1: What does "IsPlayerNPC" mean?
2: it's really my first time to see the "continue;" thingy, what is meant with that?
3: What does "GetPlayerPoolSize()+1; --i!=-1" do/mean? I know it's for the loop))
4: If I remove the
PHP код:
SendRangeMessage(); 
in the CMD:me , the message does not display lol..., I want the whole server to see the /me

5: Really appreciated!! I'll surely rep+ you later.


Re: Any idea ? - JasonSchneider - 13.09.2015

FROM
Код:
//Usage for /me:
CMD:me(playerid,params[])
{
    if(isnull(params)) return SendClientMessage(playerid,-1,"Type: /me [Text]");
    new string[145];
    GetPlayerName(playerid,string,MAX_PLAYER_NAME);
    format(string,sizeof(string),"* %s %s",string,params);
    SendRangeMessage(playerid,purple,string,25.0); //Range 25 feet...and color purple
    return 1;
}
TO!
Код:
//Usage for /me:
CMD:me(playerid,params[])
{
    if(isnull(params)) return SendClientMessage(playerid,-1,"Type: /me [Text]");
    new string[145];
    GetPlayerName(playerid,string,MAX_PLAYER_NAME);
    format(string,sizeof(string),"* %s %s",string,params);
    SendClientMessageToAll(purple, string);
    return 1;
}



AW: Re: Any idea ? - Kaliber - 13.09.2015

Quote:
Originally Posted by saffierr
Посмотреть сообщение
I've tested it and it works fine, although I've got a few questions.

1: What does "IsPlayerNPC" mean?
2: it's really my first time to see the "continue;" thingy, what is meant with that?
3: What does "GetPlayerPoolSize()+1; --i!=-1" do/mean? I know it's for the loop))
4: If I remove the
PHP код:
SendRangeMessage(); 
in the CMD:me , the message does not display lol..., I want the whole server to see the /me

5: Really appreciated!! I'll surely rep+ you later.
1. It checks if the Player is NPC (Bot) or not...
2. The continue thing means, that if the player is not connected or is an NPC or is not in the range..the loop just goes on..and check the next player (value)..
3. Its the same like for(new i; i<MAX_PLAYERS; i++) but it is a lot faster
4. Oh, i thought you wanna show the /me command only in a small range..thats usually used...if you want to send it to all...just use the Code above me


Re: Any idea ? - saffierr - 13.09.2015

ah stupid me, thanks lol, dayumm stupid me, ofc should've think first....
SendClientMessageToAll(); lol
ty for the reminder tho.


Re: Any idea ? - JasonSchneider - 13.09.2015

No need to call yourself stupid and anyway no problem


Re: Any idea ? - saffierr - 13.09.2015

@Kaliber, thank you alot tho, have learned something new again!