See the /me command in 5 meters -
davelord - 11.02.2011
Hey, how can i make my /me command so, that only players not further then 5 meters can c it?
Re: See the /me command in 5 meters - [03]Garsino - 11.02.2011
Use foreach to loop trough all connected players. Then use
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint to check if the loop itterator is in range of the player. If they are then send the message.
Re: See the /me command in 5 meters -
davelord - 11.02.2011
I just got no idea how to do this.
Re: See the /me command in 5 meters - [03]Garsino - 11.02.2011
I just told you how? Now it's up to
you to do it
yourself.
Re: See the /me command in 5 meters -
Popz - 11.02.2011
Step 1: Learn to code.
Step 2: Learn to be able to research things yourself.
Re: See the /me command in 5 meters -
Mean - 11.02.2011
ZCMD
pawn Код:
CMD:me( playerid, params[ ] )
{
for( new i = 0; i < MAX_PLAYERS; i++ )
{
new Float:x, Float:y, Float:z;
GetPlayerPos( i, x, y, z );
if ( IsPlayerInRangeOfPoint ( i, 5.0, x, y, z ) ) // You can always change the range
{
if ( i == playerid ) continue;
new string[ 128 ];
new pName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, pName, sizeof pName );
format( string, sizeof string, "%s %s", pName, params );
SendClientMessage( i, 0xAAAAAA, string );
}
}
return 1;
}
Re: See the /me command in 5 meters -
jameskmonger - 11.02.2011
Psuedocode:
Foreach -> IsPlayerInRangeofPoint( otherplayerid, getpos(playerid), 5) -> sendclientmessage(otherplayerid)
Re: See the /me command in 5 meters -
davelord - 11.02.2011
Can someone give me a /me command, just like the ZCMD but then not ZCMD but the normal command stuff
Re: See the /me command in 5 meters -
Mean - 11.02.2011
pawn Код:
if (strcmp("/me", cmdtext, true, 3) == 0)
{
for( new i = 0; i < MAX_PLAYERS; i++ )
{
new Float:x, Float:y, Float:z;
GetPlayerPos( i, x, y, z );
if ( IsPlayerInRangeOfPoint ( i, 5.0, x, y, z ) ) // You can always change the range
{
if ( i == playerid ) continue;
new string[ 128 ];
new pName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, pName, sizeof pName );
format( string, sizeof string, "%s %s", pName, cmdtext );
SendClientMessage( i, 0xAAAAAA, string );
}
}
return 1;
}
Re: See the /me command in 5 meters - [03]Garsino - 11.02.2011
Quote:
Originally Posted by Mean
pawn Код:
if (strcmp("/me", cmdtext, true, 3) == 0) { for( new i = 0; i < MAX_PLAYERS; i++ ) { new Float:x, Float:y, Float:z; GetPlayerPos( i, x, y, z ); if ( IsPlayerInRangeOfPoint ( i, 5.0, x, y, z ) ) // You can always change the range { if ( i == playerid ) continue; new string[ 128 ]; new pName[ MAX_PLAYER_NAME ]; GetPlayerName( playerid, pName, sizeof pName ); format( string, sizeof string, "%s %s", pName, cmdtext ); SendClientMessage( i, 0xAAAAAA, string ); } } return 1; }
|
Please test your code before you post. That code will send the message to every loop itteration in range of their
own position. Also, please do not post finished code to people like this. They'll come to this section and ask basic questions like this
all the time because they do not learn anything by people like you giving them finished code.
Also, to topic poster. I see
no reason to use strcmp as a command processor. There are better ones out there, so why not use them? Or wait, you downloaded The Godfather script, edited it and claimed it as your own. And now you use and learn from the bad code in that script.