Help: Command to make Player say certain thing
#1

What I would like is a command (/greet) that checks if a person IsACop (defined already in my GM) and if they are it makes them say "Hello, I'm (officer name/persons name that used /greet) with the Los Santos Police Department. Do you know why I stopped you today?"

Can someone please explain how to do this? I am a begginer scripter, so help would be great!

Please & Thanks: jakejohnsonusa
Reply
#2

PHP Code:
CMD:greet(playeridparams[])
{
new 
MSG[250];
new 
Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
if(
PlayerInfo[playerid][pCop] == true)
    {
    
format(MSG,sizeof(MSG),"Hello, I'm %s [Police Officer] with the Los Santos Police Department. Do you know why I stopped you today?"Name);
    
SendClientMessageToAll(GREEN,MSG);
return 
1;

Reply
#3

I see SendClientMessageToAll(GREEN,MSG); ... meaning it's not normal talking, I would like to know how to send the msg as normal talking. It will be for my RP server when an officer does a traffic stop...

Thanks for your help though, +1Rep

Please help me do this: jakejohnsonusa
Reply
#4

Why don't you let the cop say whatever he wants. I don't see any use in the cmd.
Reply
#5

The. command is a special cmd they can use, but I just really want to learn how to do this. Anyone that can help, please?

-jakejohnsonusa
Reply
#6

Quote:
Originally Posted by jakejohnsonusa
View Post
I see SendClientMessageToAll(GREEN,MSG); ... meaning it's not normal talking, I would like to know how to send the msg as normal talking. It will be for my RP server when an officer does a traffic stop...

Thanks for your help though, +1Rep

Please help me do this: jakejohnsonusa
What do you mean??
So the message will be sent only for the players that are near the police officer?
Reply
#7

Yea basically. Like /greet would be the same as pressing F6 and typing it...
Reply
#8

Not tested:

PHP Code:
public OnPlayerCommandText(playeridcmdtext[])
{
new 
MSG[250];
new 
Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
    if (
strcmp("/greet"cmdtexttrue10) == 0)
    {
        if(
PlayerInfo[playerid][pCop] == 1){
            if(
PlayerToPlayer(playerid,510.0)){
                
format(MSG,sizeof(MSG),"Hello, I'm %s [Police Officer] with the Los Santos Police Department. Do you know why I stopped you today?"Name);
                
SendClientMessage(playeridCOLOR_WHITEMSG);{
        return 
1;
    }
    return 
0;
}
stock PlayerToPlayer(playeridtargetidFloat:distance)
{
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playerid,x,y,z);
    if(
IsPlayerInRangeOfPoint(targetid,distance,x,y,z))
    {
        return 
true;
    }
    return 
false;

Reply
#9

Thanks! I will test add and test it soon! Thanks!
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)