Coding help
#1

Hello I want to add some codes were anyone can use it in my server (civillians and cops).

When someone types 10-20 I want it to say there location in the server? (I want it to be just 10-20 NOT /10-20)

Once I know how to do one, I will be able to do the rest.

Also when someone types 10-0 I want it to say CAUTION!!! <-- Like that.
Can anybody post here how to do these codes?

I got the police codes from here: http://www.radiolabs.com/police-codes.html
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, text[])
{
  if(!strcmp(text, "10-20", true))
  {
    new Float:x, Float:y, Float:z, string[100], name[MAX_PLAYER_NAME];
    GetPlayerPos(playerid, x, y, z);
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s's position: %f, %f, %f", name, x, y, z);
    SendClientMessageToAll(0xFFFFFFAA, string);
    return 0;
  }
  return 1;
}
Reply
#3

Quote:
Originally Posted by Sascha
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, text[])
{
  if(!strcmp(text, "10-20", true))
  {
    new Float:x, Float:y, Float:z, string[100], name[MAX_PLAYER_NAME];
    GetPlayerPos(playerid, x, y, z);
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s's position: %f, %f, %f", name, x, y, z);
    SendClientMessageToAll(0xFFFFFFAA, string);
    return 0;
  }
  return 1;
}
Were abouts do I add this code?
Under the onplayercommandtext?
Reply
#4

I'd put it under OnPlayerText since you don't want it to be /10-20.
Reply
#5

Anybody write me a code for 10-0?
I want it to say CAUTION!!
Reply
#6

?
Reply
#7

Quote:
Originally Posted by Beginnercoder
Посмотреть сообщение
Anybody write me a code for 10-0?
I want it to say CAUTION!!
I'm not sure what you meant...
But
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(!strcmp(text, "10-0", true))
    {
        SendClientMessageToAll(0xFF0000FF, "CAUTION");
        return 0;
    }
    return 1;
}
Reply
#8

These codes give me errors, are you sure they are correct?

Edit:
PHP код:
public OnPlayerText(playeridtext[])
{
    if(!
strcmp(text"10-0"true))
    {
        
SendClientMessageToAll(0xFF0000FF"CAUTION");
        return 
0;
    }
    return 
1;

Ok I got that to work but I had to delete
PHP код:
    return 1;

to get it to work but in game when I type it, it just says CAUTION, it doesn't say who said it, how do I get it to say who said it?
Reply
#9

pawn Код:
if(!strcmp(text, "10-0", true))
{
     new Name[MAX_PLAYER_NAME], Msg[45];
     GetPlayerName(playerid, Name, sizeof(Name));
     format(Msg, sizeof(Msg), "%s says Caution!" , Name)
     SendClientMessageToAll(0xFF0000FF, Msg);
}
and Also, use [ pawn ] brackets for your code.
Reply
#10

Quote:
Originally Posted by Beginnercoder
Посмотреть сообщение
These codes give me errors, are you sure they are correct?

Edit:
PHP код:
public OnPlayerText(playeridtext[])
{
    if(!
strcmp(text"10-0"true))
    {
        
SendClientMessageToAll(0xFF0000FF"CAUTION");
        return 
0;
    }
    return 
1;

Ok I got that to work but I had to delete
PHP код:
    return 1;

to get it to work but in game when I type it, it just says CAUTION, it doesn't say who said it, how do I get it to say who said it?
LoL i knew if would be errors if you had other things under "OnPlayerText" (I thought you knew that, how to fix it i mean..)

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(!strcmp(text, "10-0", true))
    {
        SendClientMessageToAll(0xFF0000FF, "CAUTION");
        return 0;
    }
    //Rest of code
    //Rest of code
    //Rest of code
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)