SA-MP Forums Archive
Roleplay chat... i must help - 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: Roleplay chat... i must help (/showthread.php?tid=507511)



Roleplay chat... i must help - Lirbo - 17.04.2014

How to do roleplay chat?... This is shows the message only to the play who sended the message... i want it will send to everyone in this range... (sorry for bad english)
PHP код:
public OnPlayerText(playeridtext[])
{
    
format(String,sizeof(String),"%s says: %s",GetName(playerid),text);
    
GetPlayerPos(playerid,X,Y,Z);
    if(
IsPlayerInRangeOfPoint(playerid13.0XYZ)){
    
SendClientMessage(playerid,-1,String);}else{return 0;}
    return 
0;




Re: Roleplay chat... i must help - DarkLored - 17.04.2014

here use this stock

pawn Код:
stock PlayerToPlayer(playerid,targetid,Float:distance)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid,x,y,z);
    if(IsPlayerInRangeOfPoint(targetid,distance,x,y,z))
    {
        return true;
    }
    return false;
}
pawn Код:
new targetid;
if(IsPlayerToPlayer(playerid, targetid, 10))



Re: Roleplay chat... i must help - Lirbo - 17.04.2014

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
here use this stock

pawn Код:
stock PlayerToPlayer(playerid,targetid,Float:distance)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid,x,y,z);
    if(IsPlayerInRangeOfPoint(targetid,distance,x,y,z))
    {
        return true;
    }
    return false;
}
pawn Код:
new targetid;
if(IsPlayerToPlayer(playerid, targetid, 10))
umm it's showes the message only for me..
pawn Код:
public OnPlayerText(playerid, text[])
{
    new targetid;
    format(String,sizeof(String),"%s says: %s",GetName(playerid),text);
    if(PlayerToPlayer(playerid,targetid,13)){
    SendClientMessage(targetid,-1,String);}
    return 0;
}



Re: Roleplay chat... i must help - DarkLored - 17.04.2014

put the if statement above the format that should work


Re: Roleplay chat... i must help - Lirbo - 17.04.2014

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
put the if statement above the format that should work
What do you mean bro? i putted the stock... it's not error... its just not shows the message to other people.. only for me


Re: Roleplay chat... i must help - DarkLored - 18.04.2014

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(PlayerToPlayer(playerid,i,13))
   {
       format(String,sizeof(String),"%s says: %s",GetName(playerid),text);
       SendClientMessage(targetid,-1,String);
   }
}
Sorry forgot that you need to use MAX_PLAYERS for this one


Re: Roleplay chat... i must help - Lirbo - 18.04.2014

One error... sorry for that :P
pawn Код:
public OnPlayerText(playerid, text[])
{
    new targetid
    for(new i = 0; i < MAX_PLAYERS; i++){
    if(PlayerToPlayer(playerid,i,13)){
    format(String,sizeof(String),"%s says: %s",GetName(playerid),text);
    SendClientMessage(targetid,-1,String);}}
    return 0;
}
pawn Код:
error 001: expected token: ";", but found "for"
The problem's line:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)



Re: Roleplay chat... i must help - DarkLored - 18.04.2014

remove the targetid you don't need it i was mistaken


Re: Roleplay chat... i must help - Lirbo - 18.04.2014

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
remove the targetid you don't need it i was mistaken
Thanks alot