19.09.2011, 15:52
hi ill post the code and tell the problem
whoever i select and the level it always gives that player Lvl 0 admin anyone know why
here is the full code
Please Help this script is vital for my server
Код:
#include <a_samp> #define ORANGE 0xAAFF00FF enum Info { AdminLevel }; new PlayerInfo[MAX_PLAYERS][Info]; public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256], idx; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/makeadmin", true) == 0) { new string[128]; new tmp[256]; new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME]; new giveplayerid; tmp = strtok(cmdtext, idx); giveplayerid = strval(tmp); if (IsPlayerAdmin(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, ORANGE, "USAGE: /makeadmin [playerid] [level]"); SendClientMessage(playerid, ORANGE, "FUNCTION: Player will be an admin."); return 1; } tmp = strtok(cmdtext, idx); new level = strval(tmp); if(giveplayerid != INVALID_PLAYER_ID) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, player, sizeof(player)); PlayerInfo[giveplayerid][AdminLevel] = level; printf("Admin %s made %s a level %d admin.", player, giveplayer, level); format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player); SendClientMessage(giveplayerid, 0x00C2ECFF, string); format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[giveplayerid][AdminLevel]); SendClientMessage(playerid, 0x00C2ECFF, string); } else { format(string, sizeof(string), "%s(%i) is not online right now, Sorry.", giveplayer, giveplayerid); SendClientMessage(playerid, 0xE60000FF, string); } } else { SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!"); } return 1; } return 1; }
here is the full code
Код:
#include <a_samp> #define ORANGE 0xAAFF00FF enum Info { AdminLevel }; new PlayerInfo[MAX_PLAYERS][Info]; public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256], idx; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/makeadmin", true) == 0) { new string[128]; new tmp[256]; new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME]; new giveplayerid; tmp = strtok(cmdtext, idx); giveplayerid = strval(tmp); if (IsPlayerAdmin(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, ORANGE, "USAGE: /makeadmin [playerid] [level]"); SendClientMessage(playerid, ORANGE, "FUNCTION: Player will be an admin."); return 1; } tmp = strtok(cmdtext, idx); new level = strval(tmp); if(giveplayerid != INVALID_PLAYER_ID) { GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, player, sizeof(player)); PlayerInfo[giveplayerid][AdminLevel] = level; printf("Admin %s made %s a level %d admin.", player, giveplayer, level); format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player); SendClientMessage(giveplayerid, 0x00C2ECFF, string); format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[giveplayerid][AdminLevel]); SendClientMessage(playerid, 0x00C2ECFF, string); } else { format(string, sizeof(string), "%s(%i) is not online right now, Sorry.", giveplayer, giveplayerid); SendClientMessage(playerid, 0xE60000FF, string); } } else { SendClientMessage(playerid, 0xE60000FF, "You are not a lead admin!"); } return 1; } if(strcmp(cmd, "/Admin_Commands", true) == 0) { SendClientMessage(playerid, ORANGE, "This Command Is A Work In Progress Untill BAdmin Is Complete"); return 1; } if(strcmp(cmd, "/Kick", true) == 0) { new string[128]; new tmp[256]; new player[MAX_PLAYER_NAME], kickplayer[MAX_PLAYER_NAME]; new kickplayerid; tmp = strtok(cmdtext, idx); kickplayerid = strval(tmp); if(PlayerInfo[playerid][AdminLevel] == 1) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, ORANGE, "USAGE: /kick [playerid]."); SendClientMessage(playerid, ORANGE, "FUNCTION: Kick a player."); return 1; } tmp = strtok(cmdtext, idx); if(kickplayerid != INVALID_PLAYER_ID) { GetPlayerName(kickplayerid, kickplayer, sizeof(kickplayer)); GetPlayerName(playerid, player, sizeof(player)); printf("Admin %s Has Kicked %s.", player, kickplayer); format(string, sizeof(string), "You Have Been Kicked By %s.", player); SendClientMessage(kickplayerid, 0x00c2ecff, string); format(string, sizeof(string), "You Have Kicked %s.", kickplayer); SendClientMessage(playerid, 0x00c2ecff, string); Kick(kickplayerid); } else { format(string, sizeof(string), "%s(%i) is not online right now, Sorry.", kickplayer, kickplayerid); SendClientMessage(playerid, 0x00c2ecff, string); } } else { SendClientMessage(playerid, 0xE6000FF, "You Are Not A Moderator!"); } return 1; } if(strcmp(cmd, "/Ban", true) == 0) { new string[128]; new tmp[256]; new player[MAX_PLAYER_NAME], banplayer[MAX_PLAYER_NAME]; new banplayerid; new reason; tmp = strtok(cmdtext, idx); banplayerid= strval(tmp); if(PlayerInfo[playerid][AdminLevel] == 2) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, ORANGE, "USAGE: /Ban [playerid] [reason]."); SendClientMessage(playerid, ORANGE, "FUNCTION: Bans a player."); return 1; } if(banplayerid != INVALID_PLAYER_ID) { tmp = strtok(cmdtext, idx); GetPlayerName(banplayerid, banplayer, sizeof(banplayer)); GetPlayerName(playerid, player, sizeof(player)); printf("Admin: %s Has Banned: %s Because: %d.", player, banplayer, reason); format(string, sizeof(string), "You Have Been Banned By: %s Because: %d.", player, reason); SendClientMessage(banplayerid, 0x00c2ecff, string); format(string, sizeof(string), "You Have Banned: %s Because: %d.", banplayer, reason); SendClientMessage(playerid, 0x00c2ecff, string); Ban(banplayerid); } else { format(string, sizeof(string), "%s(%i) is not online right now, Sorry.", banplayer, banplayerid); SendClientMessage(playerid, 0x00c2ecff, string); } } else { SendClientMessage(playerid, 0xE60000FF, "You Are Not a Super Moderator!"); } return 1; } if(strcmp(cmd, "/Get", true) == 0) { new string[128]; new tmp[256]; new player[MAX_PLAYER_NAME], getplayer[MAX_PLAYER_NAME]; new getplayerid; tmp = strtok(cmdtext, idx); getplayerid = strval(tmp); if(PlayerInfo[playerid][AdminLevel] == 1) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, ORANGE, "USAGE: /Get [playerid]."); SendClientMessage(playerid, ORANGE, "FUNCTION: Gets a player."); return 1; } if(getplayerid != INVALID_PLAYER_ID) { tmp = strtok(cmdtext, idx); new Float:X, Float:Y, Float:Z; GetPlayerName(getplayerid, getplayer, sizeof(getplayer)); GetPlayerName(playerid, player, sizeof(player)); GetPlayerPos(playerid, X, Y, Z); printf("Admin: %s Has Gotten: %s.", player, getplayer); format(string, sizeof(string), "You Have Been Teleported to Admin: %s Position.", player); SendClientMessage(getplayerid, 0x00c2ecff, string); format(string, sizeof(string), "You Have Teleported: %s to you.", getplayer); SendClientMessage(playerid, 0x00c2ecff, string); SetPlayerPos(getplayerid, X, Y, Z); } else { format(string, sizeof(string), "%s(%i) is not online right now, Sorry.", getplayer, getplayerid); SendClientMessage(playerid, 0x00c2ecff, string); } } else { SendClientMessage(playerid, 0xE60000FF, "You Are Not a moderator!"); } return 1; } if(strcmp(cmd, "/Goto", true) == 0) { new string[128]; new tmp[256]; new player[MAX_PLAYER_NAME], gotoplayer[MAX_PLAYER_NAME]; new gotoplayerid; tmp = strtok(cmdtext, idx); gotoplayerid = strval(tmp); if(PlayerInfo[playerid][AdminLevel] == 1) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, ORANGE, "USAGE: /Goto [playerid]."); SendClientMessage(playerid, ORANGE, "FUNCTION: Sets your position to that of the selected player"); return 1; } if(gotoplayerid != INVALID_PLAYER_ID) { tmp = strtok(cmdtext, idx); new Float:X, Float:Y, Float:Z; GetPlayerName(gotoplayerid, gotoplayer, sizeof(gotoplayer)); GetPlayerName(playerid, player, sizeof(player)); GetPlayerPos(gotoplayerid, X, Y, Z); printf("Admin: %s Has Teleported to: %s.", player, gotoplayer); format(string, sizeof(string), "You Have Teleported to: %s.", gotoplayer); SendClientMessage(playerid, 0x00c2ecff, string); SetPlayerPos(playerid, X, Y, Z); } else { format(string, sizeof(string), "%s(%i) is not online right now, Sorry.", gotoplayer, gotoplayerid); SendClientMessage(playerid, 0x00c2ecff, string); } } else { SendClientMessage(playerid, 0xE60000FF, "You Are Not a Moderator!"); } return 1; } return 1; } public OnPlayerConnect(playerid) { PlayerInfo[playerid][AdminLevel] = 0; return 1; } stock strtok(const string[], &index) { new length = strlen(string); while ((index < length) && (string[index] <= ' ')) { index++; } new offset = index; new result[20]; while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1))) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; }