Admin chat command would it work? -
DarkKillerWithPride<3 - 05.01.2012
Hey,
Normally I will use a command based asay command however, I was using this when I first started out scripting so I have now decided to change this method to something slightly different which is "#", I am hoping for it to work but before I can test it I would like someone to tell me if it looks okay as I cannot currently test it as my GTA:SA has been broken by someone VERY annoying in my family!
pawn Код:
public OnPlayerText(playerid,text[])
{
/* if(DisablePlayersCapKeys[playerid])
{
new Text[128];
format(Text,sizeof(Text),"%s",DisableCaps(playerid));
SendClientMessageToAll(GetPlayerColor(playerid),Text);
return 0;
}*/
if(strcmp(text,"#",true,1))
{
new admin;
strdel(text,0,1);
PlayerInfo[playerid][pAdmin] = admin;
new string[128];
switch(admin)
{
case 1: format(string,sizeof(string),"Moderator %s: %s",ReturnPlayerName(playerid));
case 2: format(string,sizeof(string),"Junior Admin %s: %s",ReturnPlayerName(playerid));
case 3: format(string,sizeof(string),"Senior Admin %s: %s",ReturnPlayerName(playerid));
case 4: format(string,sizeof(string),"Head Admin %s: %s",ReturnPlayerName(playerid));
case 1337: format(string,sizeof(string),"Administator Director %s: %s",ReturnPlayerName(playerid));
case 1338: format(string,sizeof(string),"Server Owner %s: %s",ReturnPlayerName(playerid));
}
SendClientMessageToAdmins(COLOR_PURPLE,string);
return 0;
}
return 0;
}
What I would like to find out is if the cases that I use would work and strdel is correct. Thanks!
-Dark
Re: Admin chat command would it work? - suhrab_mujeeb - 05.01.2012
Or more simply use
pawn Код:
if(text[0] == '#')
{
format(str, 128, "%s: %s", name, text[1]);
}
Just an example since your code had alot of mistakes.
Re: Admin chat command would it work? -
DarkKillerWithPride<3 - 05.01.2012
Could you please explain the mistakes a Little further also I need to use case's for players admin level as %s: %s could be mistaken as normal chat.
Re: Admin chat command would it work? -
[ABK]Antonio - 05.01.2012
pawn Код:
stock LevelName(playerid)
{
new LevelNamee[22];
switch(PlayerInfo[playerid][pAdmin])
{
case 0: LevelNamee = "Regular Player";
case 1: LevelNamee = "Moderator";
case 2: LevelNamee = "Junior Admin";
case 3: LevelNamee = "Senior Admin";
case 4: LevelNamee = "Head Admin";
case 1337: LevelNamee = "Administator Director";
case 1338: LevelNamee = "Server Owner";
}
return LevelNamee;
}
then
pawn Код:
format(string,sizeof(string), "[%s]%s(%d): %s", LevelName(playerid), ReturnPlayerName(playerid), playerid, text[1]);
Re: Admin chat command would it work? -
DarkKillerWithPride<3 - 05.01.2012
Ahh Thanks bro
Re: Admin chat command would it work? -
[ABK]Antonio - 05.01.2012
Also, listen to suhrab_mujeeb :P
if(text[0] == "#")
means if the first character the player enters is # lets do some stuff. So we can simply do...
pawn Код:
if(text[0] == '#' && PlayerInfo[playerid][pAdmin] >= 1)
{
format(string,sizeof(string), "[%s]%s(%d): %s", LevelName(playerid), ReturnPlayerName(playerid), playerid, text[1]);
SendClientMessageToAdmins(COLOR_PURPLE,string);
return 0;
}
You can make the string variable on your own with the size you want
Re: Admin chat command would it work? -
DarkKillerWithPride<3 - 05.01.2012
Ahh I see, so basically text[0] == '#' wont require any kind of strdel etc? Or am I mistaken?
Re: Admin chat command would it work? -
[ABK]Antonio - 05.01.2012
Quote:
Originally Posted by DarkKillerWithPride<3
Ahh I see, so basically text[0] == '#' wont require any kind of strdel etc? Or am I mistaken?
|
We're using text[1] for the text...which goes from the second thing input into it so no it wouldn't need anythin
text[0] basically means the FIRST thing input...computer counting starts at 0
text[1] means that it's the second character input into the string
This forum requires that you wait 120 seconds between posts. Please try again in 55 seconds.
Re: Admin chat command would it work? -
DarkKillerWithPride<3 - 05.01.2012
Okay, thanks for your help another question how to I do unkown cases? For example:
pawn Код:
stock GetPlayerLevel(playerid)
{
new Level[50];
switch(PlayerInfo[playerid][pAdmin])
{
case 0: Level = "Regular Player";
case 1: Level = "Donating Player";
case 2: Level = "Moderator";
case 3: Level = "Junior Administrator";
case 4: Level = "Senior Administrator";
case 5: Level = "Head Administrator";
case 1337: Level = "Director Of Administration";
case 1338: Level = "Server Administrator";
default: Level = "Regular Player";
else: Level = "* Undefined Player";
}
return Level;
}
Else doesn't work.
Thanks
Re: Admin chat command would it work? -
[ABK]Antonio - 05.01.2012
Quote:
Originally Posted by DarkKillerWithPride<3
Okay, thanks for your help another question how to I do unkown cases? For example:
pawn Код:
stock GetPlayerLevel(playerid) { new Level[50]; switch(PlayerInfo[playerid][pAdmin]) { case 0: Level = "Regular Player"; case 1: Level = "Donating Player"; case 2: Level = "Moderator"; case 3: Level = "Junior Administrator"; case 4: Level = "Senior Administrator"; case 5: Level = "Head Administrator"; case 1337: Level = "Director Of Administration"; case 1338: Level = "Server Administrator"; default: Level = "Regular Player"; else: Level = "* Undefined Player"; } return Level; }
Else doesn't work.
Thanks
|
default
EDIT: if default doesn't work...there's no reason for an else statement lol...you can add checks into the command for invalid player and what not