01.08.2012, 02:20
Whenever I do some command it says Unknown command...
This is my Public cmd text
Also I used ZCMD for my admin commands
There are no errors while compiling.
This is my Public cmd text
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
//ADMIN COMMANDS
if(strcmp("/kick", cmdtext, true) == 0)
{
if(PlayerInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid, COLOR_RED, "<!>You are not TDM administrator!");
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/kick", true) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_RED, "<!>Usage: /kick [playerid]");
Kick(strval(tmp));
return 1;
}
}
}
if(strcmp("/weather", cmdtext, true) == 0)
{
if(PlayerInfo[playerid][pAdminLevel] < 2) return SendClientMessage(playerid, COLOR_RED, "<!>You are not TDM administrator!");
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/weather", true) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
SetWeather(1);
return 1;
}
}
}
//NORMAL COMMANDS
if(!strcmp(cmdtext, "/levels", true, 6))
{
SendClientMessage(playerid, COLOR_WHITE, "<!>0-70: Deagle and 100 HP");
SendClientMessage(playerid, COLOR_WHITE, "<!>70-100: Deagle, Shotgun, 100 HP");
SendClientMessage(playerid, COLOR_WHITE, "<!>100-200: Deagle, Shotgun, MP5, 100 HP");
SendClientMessage(playerid, COLOR_WHITE, "<!>200-400: Deagle, Shotgun, MP5, AK-47, 100 HP, 100armour");
SendClientMessage(playerid, COLOR_WHITE, "<!>400-100: Deagle, Shotgun, MP5, M4, 100HP, 100 Armour");
SendClientMessage(playerid, COLOR_WHITE, "<!>1000-2000: Deagle, Spaz, M4, 100HP, 100 Armour");
SendClientMessage(playerid, COLOR_WHITE, "<!>Over 2000 score, you will be able to choose your guns!");
SendClientMessage(playerid, COLOR_WHITE, "<!>Also on 2000 score you will receive buff with 150 HP and 100 Armour (Bronze Donation)");
return 1;
}
if(!strcmp(cmdtext, "/scratchcard", true, 11))
{
if(GetPlayerMoney(playerid) < 300) return SendClientMessage(playerid, COLOR_RED, "<!>Not enought money for this. Required 300$");
GivePlayerMoney(playerid, -300);
new str[44];
new randmoney = random(1001) - 100;
format(str, sizeof(str), " >> You bought scratch card! You won %d", randmoney);
SendClientMessage(playerid, 0xffffffff, str);
GivePlayerMoney(playerid, randmoney);
return 1;
}
if(!strcmp(cmdtext, "/me", true, 3))
{
if(!cmdtext[3])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /me [action]");
new str[128];
GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "* %s %s", str, cmdtext[4]);
SendClientMessageToAll(0xFFFF00AA, str);
return 1;
}
if(!strcmp(cmdtext, "/help", true, 4))
{
SendClientMessage(playerid, COLOR_YELLOW, "|===========================================================|");
SendClientMessage(playerid, COLOR_WHITE, "/help, /rules, /randomweapon, /me, /scratchcard");
SendClientMessage(playerid, COLOR_WHITE, "Radio: /listentoradio, /cancelstream");
SendClientMessage(playerid, COLOR_WHITE, "/guns, /melee, /misc, /time");
SendClientMessage(playerid, COLOR_YELLOW, "|===========================================================|");
return 1;
}
if(!strcmp(cmdtext, "/randomweapon", true, 12))
{
if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid, COLOR_RED, "<!>You don't have enought money for that!");
GiveRandomWeapon(playerid);
GivePlayerMoney(playerid, -500);
return 1;
}
if(!strcmp(cmdtext, "/rules", true, 5))
{
SendClientMessage(playerid, COLOR_RED, "|===========================================================|");
SendClientMessage(playerid, COLOR_WHITE, "|1. Do not use cheats!|");
SendClientMessage(playerid, COLOR_WHITE, "|2. Do not troll!|");
SendClientMessage(playerid, COLOR_WHITE, "|3. Do not C-bug!|");
SendClientMessage(playerid, COLOR_WHITE, "|4. Do not do Team Killing!");
SendClientMessage(playerid, COLOR_WHITE, "|5. Do not Spawn Kill!");
SendClientMessage(playerid, COLOR_WHITE, "|6. Do not troll!");
SendClientMessage(playerid, COLOR_WHITE, "|7. Do not spam chat!");
SendClientMessage(playerid, COLOR_WHITE, "|8. Do not insult!");
SendClientMessage(playerid, COLOR_WHITE, "|9. Do not advertise!");
SendClientMessage(playerid, COLOR_WHITE, "|10. Do not Drive By as driver!");
SendClientMessage(playerid, COLOR_WHITE, "|11. Do not Car park people!");
SendClientMessage(playerid, COLOR_WHITE, "|12. If you see someone rule breaking /report!");
SendClientMessage(playerid, COLOR_WHITE, "|13. Do not do Chicken Runing!");
SendClientMessage(playerid, COLOR_RED, "|===========================================================|");
return 1;
}
if(!strcmp(cmdtext, "/heal", true, 4))
{
if(UsedHeal[playerid]) return SendClientMessage(playerid, COLOR_RED, "<!>You already used this command! You will be able to use it after death!");
{
if(GetPlayerMoney(playerid) < 200) return SendClientMessage(playerid, COLOR_RED, "<!>You dont have enought money! Required 200$");
{
SetPlayerHealth(playerid, 100);
UsedHeal[playerid] = true;
GivePlayerMoney(playerid, -200);
return 1;
}
}
}
if(!strcmp(cmdtext, "/armour", true, 5))
{
if(UsedHeal[playerid]) return SendClientMessage(playerid, COLOR_RED, "<!>You already used this command! You will be able to use it after death!");
{
if(GetPlayerMoney(playerid) < 300) return SendClientMessage(playerid, COLOR_RED, "<!>You dont have enought money! Required 300$");
{
SetPlayerArmour(playerid, 100);
UsedHeal[playerid] = true;
GivePlayerMoney(playerid, -300);
return 1;
}
}
}
if (strcmp("/listentoradio", cmdtext, true) == 0)
{
SendClientMessage(playerid, COLOR_BLUE, "=====What sort of music you want to listen? Check genrees and commands bellow!");
SendClientMessage(playerid, COLOR_WHITE, "Stations: /blues, /classical, /country, /decades"); //finished
SendClientMessage(playerid, COLOR_WHITE, "Stations: /easylistening, /Electronic, /Folk");
SendClientMessage(playerid, COLOR_WHITE, "Stations: /jazz, /latin, /metal");
SendClientMessage(playerid, COLOR_WHITE, "Stations: /pop, /newage, /urban (R&B)");
SendClientMessage(playerid, COLOR_WHITE, "Stations: /rap, /raggae, /rock");
SendClientMessage(playerid, COLOR_RED, "Important: To cancel music, use /cancelstream"); //finished
SendClientMessage(playerid, COLOR_BLUE, "=====Each ganree got around 5-10 stations atleast. Pick carefully! ENJOY!");
return 1;
}
if (strcmp("/cancelstream", cmdtext, true) == 0)
{
StopAudioStreamForPlayer(playerid);
return 1;
}
if (strcmp("/blues", cmdtext, true) == 0)
{
//7 stations
ShowPlayerDialog(playerid,1,DIALOG_STYLE_LIST, "Blues", "1.Absolute Hits\n2.Seattle Riff\n3.Belly Up For Blues\n4.Super Blues Radio\n5.KOQX Blues Radio\n6.Big Blue Swing\n7.Blues Connections", "Play", "Close");
return 1;
}
if (strcmp("/classical", cmdtext, true) == 0)
{
//7 stations
ShowPlayerDialog(playerid,2,DIALOG_STYLE_LIST,"Classical", "1.181FM\n2.Cinemix FM\n3.Venice Classic\n4.Sky FM\n5.Otto's Opera House\n6.Abacus\n7.Connecta Classicos", "Play", "Close");
return 1;
}
if (strcmp("/country", cmdtext, true) == 0)
{
//7 Stations
ShowPlayerDialog(playerid,3,DIALOG_STYLE_LIST,"Country", "1.Roots Radio\n2.Kickin' Country\n3.Absolute Country Hits\n4.Country 108\n5.Aaron FM\n6.Boot Liquor\n7.Ocean Beach Radio", "Play", "Close");
return 1;
}
if (strcmp("/decades", cmdtext, true) == 0)
{
//7 Stations
ShowPlayerDialog(playerid,4,DIALOG_STYLE_LIST,"Decades", "1.The Doo-Wop Express (50's)\n2.1FM (50's and 60's)\n3.Itallian Graffiati (60's and 70's)\n4.Musik Goldies (70's)\n5.Oldies 104(80's)\n6.Sky (80's)\n7.Big R Radio(90's)", "Play", "Close");
return 1;
}
if (strcmp("/easylistening", cmdtext, true) == 0)
{
ShowPlayerDialog(playerid,5,DIALOG_STYLE_LIST,"Easy Listening", "1.", "Play", "Close");
return 1;
}
if(strcmp(cmdtext, "/guns", true) == 0) //All heavy and hand guns
{
ShowPlayerDialog(playerid,6,DIALOG_STYLE_LIST,"Weapons","1. Deagle (250$)\n2.MP5 (500$)\n3.m4 (1000$)\n4. AK-47 (1000$)\n5. SD Pistol (150$)\n6. 9mm (150$)\n7. Shotgun (300$)\n8. Micro SMG (500$)\n9. Sawnoff Shotgun (700$)\n10.Combat Shotgun (1000$)\n11. Tec-9 (500$)\n12.Country Rifle (1000$)\n13. Sniper Rifle (2000$)\n14. RPG (5000$)\n14. Flame Thrower (4000$)", "Buy", "Close");
return 1;
}
if(strcmp(cmdtext, "/melee", true) == 0) //All melee weapons
{
ShowPlayerDialog(playerid,7,DIALOG_STYLE_LIST, "Melee Weapons", "1.Brass Knuckles (20$)\n2.Golf Club (30$)\n3.Night Stick (30$)\n4.Knife (50$)\n5. Bat (50$)\n6.Katana (100$)\n7.Chainsaw (200$) ", "Buy", "Close");
return 1;
}
if(strcmp(cmdtext, "/misc", true) == 0) //Bombs basically
{
ShowPlayerDialog(playerid,8, DIALOG_STYLE_LIST, "Misc", "1.Bomb (2000$)\n2.Molotov (1500$)\n3.Tear Gas (1000$) ", "Play", "Close");
return 1;
}
if(strcmp(cmdtext, "/time", true) == 0) //Time command.
{
new Hour, Minute, Second;
gettime(Hour, Minute, Second);
printf("%02d:%02d:%02d", Hour, Minute, Second);
return 1;
}
if(!strcmp(cmdtext, "/netstats"))
{
new stats[400+1];
GetNetworkStats(stats, sizeof(stats));
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Server Network Stats", stats, "Close", "");
}
return SendClientMessage(playerid, COLOR_RED, "<!>Server: Unknown Command. Try again!");
}
Код:
CMD:ah(playerid, params[])
{
if(PlayerInfo[playerid][pAdminLevel]>1)
{
SendClientMessage(playerid, COLOR_BLUE, "Level 1: /kick, /spec");
SendClientMessage(playerid, COLOR_BLUE, "As Level 1 your duties are to follow and obey all rules, and respect higher level administrators! ");
}
if(PlayerInfo[playerid][pAdminLevel]>2)
{
SendClientMessage(playerid, COLOR_BLUE, "Level 1: /kick, /spec");
SendClientMessage(playerid, COLOR_BLUE, "Level2: ");
}
if(PlayerInfo[playerid][pAdminLevel]>3)
{
SendClientMessage(playerid, COLOR_BLUE, "Level 1: /kick, /spec");
SendClientMessage(playerid, COLOR_BLUE, "Level2: /announce ");
SendClientMessage(playerid, COLOR_BLUE, "Level3: /ban, ");
}
if(PlayerInfo[playerid][pAdminLevel]>4)
{
SendClientMessage(playerid, COLOR_BLUE, "Level 1: /kick, /spec");
SendClientMessage(playerid, COLOR_BLUE, "Level2: /announce ");
SendClientMessage(playerid, COLOR_BLUE, "Level3: /ban, ");
SendClientMessage(playerid, COLOR_BLUE, "Level4: ");
}
if(PlayerInfo[playerid][pAdminLevel]>5)
{
SendClientMessage(playerid, COLOR_BLUE, "Level 1: /kick, /spec");
SendClientMessage(playerid, COLOR_BLUE, "Level2: /announce ");
SendClientMessage(playerid, COLOR_BLUE, "Level3: /ban, ");
SendClientMessage(playerid, COLOR_BLUE, "Level4: ");
SendClientMessage(playerid, COLOR_BLUE, "Level5: ");
}
else
{
SendClientMessage(playerid, COLOR_RED, "<!>You are not administrator!");
}
return 1;
}
COMMAND:announce(playerid, params[])
{
new text[64], time, style;
if(PlayerInfo[playerid][pAdminLevel] >=2) return SendClientMessage(playerid,COLOR_RED,"Only Adminstrator can use this!");
else if (sscanf(params, "iis[64]", style, time, text)) return SendClientMessage(playerid,COLOR_RED,"Usage: /announce <style[0-6]> <time in ms> <text>");
else if (strlen(text) > 64) return SendClientMessage(playerid,COLOR_RED,"Message too long, please make it with less than 64 letters!");
else if (style == 2) return SendClientMessage(playerid,COLOR_RED,"Bug with style 2! Do not use it!");
else if (style < 0 || style > 6) return SendClientMessage(playerid,0x854900FF,"Invalid style");
else if (time > 20*1000) return SendClientMessage(playerid, COLOR_RED,"No longer than 20 seconds");
else {
GameTextForAll(text, time, style);
}
return 1;
}
CMD:kick(playerid, params[])
{
if(PlayerInfo[playerid][pAdminLevel] >= 1) {
new PID;
new reason[64];
new str[128];
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Adminname, sizeof(Adminname));
GetPlayerName(PID, Playername, sizeof(Playername));
if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /kick [playerid] [reason]");
if(!IsPlayerConnected(PID))
return SendClientMessage(playerid, COLOR_RED, "Player is not connected!");
format(str, sizeof(str), "'%s' has been kicked by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
SendClientMessageToAll(COLOR_RED, str);
Kick(PID);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You have to be level 1 Admin to use that command!"); //return this message
}
return 1;
}
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdminLevel] >= 3) {
new PID;
new reason[64];
new str[128];
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Adminname, sizeof(Adminname));
GetPlayerName(PID, Playername, sizeof(Playername));
if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /kick [playerid] [reason]");
if(!IsPlayerConnected(PID))
return SendClientMessage(playerid, COLOR_RED, "Player is not connected!");
format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s ", Playername, Adminname, reason);
SendClientMessageToAll(COLOR_RED, str);
Ban(PID);
}
else
{
SendClientMessage(playerid, COLOR_RED, "You have to be level 3 to use that command!");
}
return 1;
}
COMMAND:spec(playerid, params[])
{
new id;
if(PlayerInfo[playerid][pAdminLevel] >= 1) return 0;
if(sscanf(params,"u", id))return SendClientMessage(playerid, COLOR_BLUE, "Usage: /spec [id]");// Now this is where we use sscanf to check if the params were filled, if not we'll ask you to fill them
if(id == playerid)return SendClientMessage(playerid,COLOR_BLUE,"You cannot spec yourself.");// Just making sure.
if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, COLOR_BLUE, "Player not found!");// This is to ensure that you don't fill the param with an invalid player id.
if(IsSpecing[playerid] == 1)return SendClientMessage(playerid,COLOR_BLUE,"You are already specing someone.");// This will make you not automatically spec someone else by mistake.
GetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);// This is getting and saving the player's position in a variable so they'll respawn at the same place they typed '/spec'
Inter[playerid] = GetPlayerInterior(playerid);// Getting and saving the interior.
vWorld[playerid] = GetPlayerVirtualWorld(playerid);//Getting and saving the virtual world.
TogglePlayerSpectating(playerid, true);// Now before we use any of the 3 functions listed above, we need to use this one. It turns the spectating mode on.
if(IsPlayerInAnyVehicle(id))//Checking if the player is in a vehicle.
{
if(GetPlayerInterior(id) > 0)//If the player's interior is more than 0 (the default) then.....
{
SetPlayerInterior(playerid,GetPlayerInterior(id));//.....set the spectator's interior to that of the player being spectated.
}
if(GetPlayerVirtualWorld(id) > 0)//If the player's virtual world is more than 0 (the default) then.....
{
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));//.....set the spectator's virtual world to that of the player being spectated.
}
PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));// Now remember we checked if the player is in a vehicle, well if they're in a vehicle then we'll spec the vehicle.
}
else// If they're not in a vehicle, then we'll spec the player.
{
if(GetPlayerInterior(id) > 0)
{
SetPlayerInterior(playerid,GetPlayerInterior(id));
}
if(GetPlayerVirtualWorld(id) > 0)
{
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));
}
PlayerSpectatePlayer(playerid,id);// Letting the spectator spec the person and not a vehicle.
}
GetPlayerName(id, Name, sizeof(Name));//Getting the name of the player being spectated.
format(String, sizeof(String),"You have started to spectate %s.",Name);// Formatting a string to send to the spectator.
SendClientMessage(playerid,0x0080C0FF,String);//Sending the formatted message to the spectator.
IsSpecing[playerid] = 1;// Just saying that the spectator has begun to spectate someone.
IsBeingSpeced[id] = 1;// Just saying that a player is being spectated (You'll see where this comes in)
spectatorid[playerid] = id;// Saving the spectator's id into this variable.
return 1;// Returning 1 - saying that the command has been sent.
}
COMMAND:specoff(playerid, params[])
{
if(PlayerInfo[playerid][pAdminLevel] >= 2)return 0;// This checks if the player is logged into RCON, if not it will return 0; (Showing "SERVER: Unknown Command")
if(IsSpecing[playerid] == 0)return SendClientMessage(playerid,COLOR_BLUE,"You are not spectating anyone.");
TogglePlayerSpectating(playerid, 0);//Toggling spectate mode, off. Note: Once this is called, the player will be spawned, there we'll need to reset their positions, virtual world and interior to where they typed '/spec'
return 1;
}



Thanks for the info tho! +Rep