Coding help -
Beginnercoder - 02.02.2011
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
Re: Coding help -
Sascha - 02.02.2011
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;
}
Re: Coding help -
Beginnercoder - 02.02.2011
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?
Re: Coding help -
randomkid88 - 02.02.2011
I'd put it under OnPlayerText since you don't want it to be /10-20.
Re: Coding help -
Beginnercoder - 02.02.2011
Anybody write me a code for 10-0?
I want it to say CAUTION!!
Re: Coding help -
Beginnercoder - 02.02.2011
?
Re: Coding help - Unknown123 - 02.02.2011
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;
}
Re: Coding help -
Beginnercoder - 09.02.2011
These codes give me errors, are you sure they are correct?
Edit:
PHP код:
public OnPlayerText(playerid, text[])
{
if(!strcmp(text, "10-0", true))
{
SendClientMessageToAll(0xFF0000FF, "CAUTION");
return 0;
}
return 1;
}
Ok I got that to work but I had to delete
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?
Re: Coding help -
randomkid88 - 09.02.2011
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.
Re: Coding help - Unknown123 - 09.02.2011
Quote:
Originally Posted by Beginnercoder
These codes give me errors, are you sure they are correct?
Edit:
PHP код:
public OnPlayerText(playerid, text[])
{
if(!strcmp(text, "10-0", true))
{
SendClientMessageToAll(0xFF0000FF, "CAUTION");
return 0;
}
return 1;
}
Ok I got that to work but I had to delete 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;
}