Help with making a new msg type
#1

Well i have used many times
Код:
format(string, sizeof(string), "Stuff");
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
And to me when using alot it just gets tiring. So i was wonder if the is anyway to do something like:
Код:
formatp(stringname, sizeof(stringname), "blah blah", distance, playerid, stringname, color);
Some of you may not like the idea, thats fine. Just wondering how to do this, mostly for quickness and well improving my skills. I tried but well....Failed Epicly.
Thanks in advance.
Reply
#2

pawn Код:
new
    string[ MAX_STRING ] ;
format( string, sizeof( string ), "Stuff" ) ;
SendClientMessage( playerid, COLOR, string ) ;
this one?
Reply
#3

Erm not quite, i meant like in one string
Reply
#4

then
pawn Код:
SendClientMessage( playerid, COLOR, string... ) ;
xD
Reply
#5

Something like this? I just made it, i figured it could be useful for myself aswell.
I edited it to add a very important detail xD
pawn Код:
// USAGE/EXAMPLE: SendMessageToArea(playerid,30,COLOR_RED,"This message is RED and will be sent to all players within 30 meters.");

stock SendMessageToArea(playerid,distance,COLOR,const str[])
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    foreach(Player,i)
    {
        if(IsPlayerInRangeOfPoint(i,distance,X,Y,Z))
        {
            SendClientMessage(i,COLOR,str);
        }
    }
    return 1;
}
Reply
#6

@Mike, what is IsPlayerInCircle ( at least show the code so people who use the code can compile it without errors ) why not just simply use IsPlayerInRangeOfPoint?
Reply
#7

Edited my first post

Edited.
IsPlayerInRangeOfPoint is probably very similar, you can edit it to use that, it should be very simple..

I didn't know about that function, one i missed i guess.
Reply
#8

Код:
stock SndMsgToPlayersNearby(msg[],color,radius)
{
	for(new i=0;i<MAX_PLAYERS;i++)
	{
	    if(GetDistanceBetweenPlayers(playerid,i)<radius)
	    {
	        SendClientMessage(i,color,msg);
	    }
	}
	return 1;
}

stock GetDistanceBetweenPlayers(playerid,playerid2)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    GetPlayerPos(playerid2,x2,y2,z2);
    tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
    return floatround(tmpdis);
}
havent tested the first stock
Reply
#9

@THE_KNOWN I've already posted a function, which i edited for the better. There's no point to post a slower function.
Reply
#10

Quote:
Originally Posted by Mike Garber
Посмотреть сообщение
Something like this? I just made it, i figured it could be useful for myself aswell.
I edited it to add a very important detail xD
pawn Код:
// USAGE/EXAMPLE: SendMessageToArea(playerid,30,COLOR_RED,"This message is RED and will be sent to all players within 30 meters.");

stock SendMessageToArea(playerid,distance,COLOR,const str[])
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
    foreach(Player,i)
    {
        if(IsPlayerInRangeOfPoint(i,distance,X,Y,Z))
        {
            SendClientMessage(i,COLOR,str);
        }
    }
    return 1;
}
Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)