/makeadmin not working propely. Waird bug. -
Hello again... Well, this is driving me crazy. Any command that need ID, is working on this today started GameMode. All is right, register/login/save system is working but the damn commands no.
The Unknown Command show up when i type it.
pawn Код:
//Includes
#include <a_samp>
#include <dini>
#include <dudb>
#include <zcmd>
#include <sscanf2>
#include <foreach>
//Pragmas
#pragma unused ret_memcpy
//Defines
#define COLOR_BROWN 0x804000AA
#define COLOR_RED 0xFF0000AA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_DARKGOLD 0x808000AA
#define COLOR_CYAN 0xFF8080AA
#define COLOR_NOTADMIN 0x8B0000AA
//News
new IsLogged[MAX_PLAYERS];
new file[256];
//Enums
enum pInfo
{
AdminLevel,
VipLevel,
Money,
Score,
Warns,
BankSlot1,
BankSlot2,
BankSlot3,
HouseKey,
BusinessKey,
Car1Key,
Car2Key,
Car3Key,
Car4Key,
Car5Key,
Car6Key,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
main()
{
print("\n----------------------------------");
print("Ricardo's Role-Play by Ricardo Rodrigues");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SetGameModeText("RRP v0.01");
SetTimer("AutoSave", 10000, true);
AddPlayerClass(0, 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
IsLogged[playerid] = 0;
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(file, sizeof(file), "RicAdmin/users/%s.ini", Name);
if (!dini_Exists(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{F81414}Register", "{FFFFFF}Your account doesn't exist in our database, please insert a password below, to start the registration.", "Continue", "Quit");
}
if(fexist(file))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{F81414}Login", "{FFFFFF}Your account has been found in our database. Please insert your password below to login.", "Coninue", "Quit");
}
if(PlayerInfo[playerid][Warns] == 5)
{
SendClientMessage(playerid, COLOR_RED, "Your accounr is blocked. The maximum of 5 warns has been reached.");
Kick(playerid);
}
}
public OnPlayerDisconnect(playerid, reason)
{
new Name[24];
GetPlayerName(playerid,Name,24);
format(file, sizeof(file),"RRP/users/%s.ini",Name);
if(fexist(file))
{
dini_IntSet(file,"AdminLevel",PlayerInfo[playerid][AdminLevel]);
dini_IntSet(file,"VipLevel",PlayerInfo[playerid][VipLevel]);
dini_IntSet(file,"Money",GetPlayerMoney(playerid));
dini_IntSet(file,"Score",GetPlayerScore(playerid));
dini_IntSet(file,"Warns",PlayerInfo[playerid][Warns]);
dini_IntSet(file,"BankSlot1",PlayerInfo[playerid][BankSlot1]);
dini_IntSet(file,"BankSlot2",PlayerInfo[playerid][BankSlot2]);
dini_IntSet(file,"BankSlot3",PlayerInfo[playerid][BankSlot3]);
dini_IntSet(file,"HouseKey",PlayerInfo[playerid][HouseKey]);
dini_IntSet(file,"Businesskey",PlayerInfo[playerid][BusinessKey]);
dini_IntSet(file,"Car1Key",PlayerInfo[playerid][Car1Key]);
dini_IntSet(file,"Car2Key",PlayerInfo[playerid][Car2Key]);
dini_IntSet(file,"Car3Key",PlayerInfo[playerid][Car3Key]);
dini_IntSet(file,"Car4Key",PlayerInfo[playerid][Car4Key]);
dini_IntSet(file,"Car5Key",PlayerInfo[playerid][Car5Key]);
dini_IntSet(file,"Car6Key",PlayerInfo[playerid][Car6Key]);
IsLogged[playerid] = 0;
return 1;
}
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 1)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(file, sizeof(file), "RRP/users/%s.ini", Name);
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{F81414}Register", "{FFFFFF}Your account doesn't exist in our database, please insert a password below, to start the registration.", "Continue", "Quit");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel] = 0);
dini_IntSet(file, "VipLevel", PlayerInfo[playerid][VipLevel] = 0);
dini_IntSet(file, "Money", SetPlayerMoney(playerid, 500));
dini_IntSet(file, "Score", SetPlayerScore(playerid, 1));
dini_IntSet(file, "Warns", PlayerInfo[playerid][Warns] = 0);
dini_IntSet(file, "BankSlot1", PlayerInfo[playerid][BankSlot1] = 0);
dini_IntSet(file, "BankSlot2", PlayerInfo[playerid][BankSlot2] = 0);
dini_IntSet(file, "BankSlot3", PlayerInfo[playerid][BankSlot3] = 0);
dini_IntSet(file, "HouseKey", PlayerInfo[playerid][HouseKey] = 9999);
dini_IntSet(file, "BusinessKey", PlayerInfo[playerid][BusinessKey] = 9999);
dini_IntSet(file, "Car1Key", PlayerInfo[playerid][Car1Key] = 9999);
dini_IntSet(file, "Car2Key", PlayerInfo[playerid][Car2Key] = 9999);
dini_IntSet(file, "Car3Key", PlayerInfo[playerid][Car3Key] = 9999);
dini_IntSet(file, "Car4Key", PlayerInfo[playerid][Car4Key] = 9999);
dini_IntSet(file, "Car5Key", PlayerInfo[playerid][Car5Key] = 9999);
dini_IntSet(file, "Car6Key", PlayerInfo[playerid][Car6Key] = 9999);
SendClientMessage(playerid, COLOR_BROWN, "Your account is now registred in our database. Welcome to Ricardo's Role-Play.");
IsLogged[playerid] = 1;
}
if (dialogid == 2)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(file, sizeof(file), "RRP/users/%s.ini", Name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{F81414}Login", "{FFFFFF}Your account has been found in our database. Please insert your password below to login.", "Coninue", "Quit");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp) {
SendClientMessage(playerid, 0xFF00CC, "Wrong PW sir.");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{F81414}Login", "{FFFFFF}Your account has been found in our database. Please insert your password below to login.", "Coninue", "Quit");
}
else
{
IsLogged[playerid] = 1;
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
PlayerInfo[playerid][VipLevel] = dini_Int(file, "VipLevel");
SetPlayerMoney(playerid, dini_Int(file, "Money"));
SetPlayerScore(playerid, dini_Int(file, "Score"));
PlayerInfo[playerid][Warns] = dini_Int(file, "Warns");
PlayerInfo[playerid][BankSlot1] = dini_Int(file, "BankSlot1");
PlayerInfo[playerid][BankSlot2] = dini_Int(file, "BankSlot2");
PlayerInfo[playerid][BankSlot3] = dini_Int(file, "BankSlot3");
PlayerInfo[playerid][HouseKey] = dini_Int(file, "HouseKey");
PlayerInfo[playerid][BusinessKey] = dini_Int(file, "BusinessKey");
PlayerInfo[playerid][Car1Key] = dini_Int(file, "Car1Key");
PlayerInfo[playerid][Car2Key] = dini_Int(file, "Car2Key");
PlayerInfo[playerid][Car3Key] = dini_Int(file, "Car3Key");
PlayerInfo[playerid][Car4Key] = dini_Int(file, "Car4Key");
PlayerInfo[playerid][Car5Key] = dini_Int(file, "Car5Key");
PlayerInfo[playerid][Car6Key] = dini_Int(file, "Car6Key");
SendClientMessage(playerid, COLOR_BROWN, "You have sucefull logged in. Welcome back to Ricardo's Role-Play.");
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
//Non-Admin Message
forward NotAdmin(playerid);
public NotAdmin(playerid)
{
SendClientMessage(playerid, COLOR_NOTADMIN, "You are not admin, or hight enough to use this command.");
return 1;
}
forward AutoSave(playerid);
public AutoSave(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(file, sizeof(file), "RRP/users/%s.ini", Name);
if(fexist(file))
{
dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel]);
dini_IntSet(file, "VipLevel", PlayerInfo[playerid][VipLevel]);
dini_IntSet(file, "Money", GetPlayerMoney(playerid));
dini_IntSet(file, "Score", GetPlayerScore(playerid));
dini_IntSet(file, "Warns", PlayerInfo[playerid][Warns]);
dini_IntSet(file, "BankSlot1", PlayerInfo[playerid][BankSlot1]);
dini_IntSet(file, "BankSlot2", PlayerInfo[playerid][BankSlot2]);
dini_IntSet(file, "BankSlot3", PlayerInfo[playerid][BankSlot3]);
dini_IntSet(file, "HouseKey", PlayerInfo[playerid][HouseKey]);
dini_IntSet(file, "Businesskey", PlayerInfo[playerid][BusinessKey]);
dini_IntSet(file, "Car1Key", PlayerInfo[playerid][Car1Key]);
dini_IntSet(file, "Car2Key", PlayerInfo[playerid][Car2Key]);
dini_IntSet(file, "Car3Key", PlayerInfo[playerid][Car3Key]);
dini_IntSet(file, "Car4Key", PlayerInfo[playerid][Car4Key]);
dini_IntSet(file, "Car5Key", PlayerInfo[playerid][Car5Key]);
dini_IntSet(file, "Car6Key", PlayerInfo[playerid][Car6Key]);
return 1;
}
return 0;
}
CMD:help(playerid, params[])
{
SendClientMessage(playerid, COLOR_CYAN, "============================Help Menu===============================");
SendClientMessage(playerid, COLOR_CYAN, "[General]:");
SendClientMessage(playerid, COLOR_CYAN, "[General]:");
SendClientMessage(playerid, COLOR_CYAN, "[Vehicle]:");
SendClientMessage(playerid, COLOR_CYAN, "[House]:");
SendClientMessage(playerid, COLOR_CYAN, "[Business]:");
SendClientMessage(playerid, COLOR_CYAN, "============================Help Menu===============================");
return 1;
}
CMD:ah(playerid, params[])
{
if(PlayerInfo[playerid][AdminLevel] == 0)
{
NotAdmin(playerid);
return 1;
}
if(PlayerInfo[playerid][AdminLevel] == 1)
{
SendClientMessage(playerid, COLOR_CYAN, "============================Admin Commands===============================");
SendClientMessage(playerid, COLOR_CYAN, "[Level 1]:");
SendClientMessage(playerid, COLOR_CYAN, "============================Admin Commands===============================");
return 1;
}
if(PlayerInfo[playerid][AdminLevel] == 2)
{
SendClientMessage(playerid, COLOR_CYAN, "============================Admin Commands===============================");
SendClientMessage(playerid, COLOR_CYAN, "[Level 1]:");
SendClientMessage(playerid, COLOR_CYAN, "[Level 2]:");
SendClientMessage(playerid, COLOR_CYAN, "============================Admin Commands===============================");
return 1;
}
if(PlayerInfo[playerid][AdminLevel] == 3)
{
SendClientMessage(playerid, COLOR_CYAN, "============================Admin Commands===============================");
SendClientMessage(playerid, COLOR_CYAN, "[Level 1]:");
SendClientMessage(playerid, COLOR_CYAN, "[Level 2]:");
SendClientMessage(playerid, COLOR_CYAN, "[Level 3]:");
SendClientMessage(playerid, COLOR_CYAN, "============================Admin Commands===============================");
return 1;
}
if(PlayerInfo[playerid][AdminLevel] == 4)
{
SendClientMessage(playerid, COLOR_CYAN, "============================Admin Commands===============================");
SendClientMessage(playerid, COLOR_CYAN, "[Level 1]:");
SendClientMessage(playerid, COLOR_CYAN, "[Level 2]:");
SendClientMessage(playerid, COLOR_CYAN, "[Level 3]:");
SendClientMessage(playerid, COLOR_CYAN, "[Level 4]:");
SendClientMessage(playerid, COLOR_CYAN, "============================Admin Commands===============================");
return 1;
}
if(PlayerInfo[playerid][AdminLevel] == 5)
{
SendClientMessage(playerid, COLOR_CYAN, "============================Admin Commands===============================");
SendClientMessage(playerid, COLOR_CYAN, "[Level 1]:");
SendClientMessage(playerid, COLOR_CYAN, "[Level 2]:");
SendClientMessage(playerid, COLOR_CYAN, "[Level 3]:");
SendClientMessage(playerid, COLOR_CYAN, "[Level 4]:");
SendClientMessage(playerid, COLOR_CYAN, "[Level 5]:");
SendClientMessage(playerid, COLOR_CYAN, "============================Admin Commands===============================");
return 1;
}
return 0;
}
CMD:makeadmin(playerid, params[])
{
new id;
new AdminLevel2;
if(PlayerInfo[playerid][AdminLevel] >= 5 || IsPlayerAdmin(playerid))
{
if(!sscanf(params, "ud", id, AdminLevel2))
{
if((AdminLevel2 >= 1 && AdminLevel2 <= 5) || AdminLevel2 == 0)
{
new string[128]; new Name[MAX_PLAYER_NAME]; new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "%s Has Given You %d Admin Level.", Name, AdminLevel2);
SendClientMessage(id, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "You Gave %d Admin Level To %s.", AdminLevel2, PlayerName);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
PlayerInfo[id][AdminLevel] = AdminLevel2;
return 1;
}
else return SendClientMessage(playerid, COLOR_DARKGOLD, "Avaliable Levels: 1, 2, 3, 4 and 5.");
}
else return SendClientMessage(playerid, COLOR_DARKGOLD, "USAGE: /makeadmin [PlayerId/PartOfName] [Admin Level]");
}
else return NotAdmin(playerid);
}
CMD:admin(playerid, params[])
{
PlayerInfo[playerid][AdminLevel] = 5;
return 1;
}
COMMAND:setmoney(playerid, params[])
{
new id;
new ammount;
if(PlayerInfo[playerid][AdminLevel] >= 3)
{
if(!sscanf(params, "ui", id, ammount))
{
if(ammount <= 10000000000)
{
new string[128]; new Name[MAX_PLAYER_NAME]; new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "%s Has Given You %d.", Name, ammount);
SendClientMessage(id, COLOR_DARKGOLD, string);
format(string, sizeof(string), "You Gave %d Money To %s .", ammount, PlayerName);
SendClientMessage(playerid, COLOR_DARKGOLD, string);
SetPlayerMoney(id, ammount);
return 1;
}
else return SendClientMessage(playerid, COLOR_DARKGOLD, "You can't give so much");
}
else return SendClientMessage(playerid, COLOR_DARKGOLD, "USAGE: /setmoney [PlayerId/PartOfName] [Ammount]");
}
else return NotAdmin(playerid);
}
Thank you.
Re: /makeadmin not working propely. Waird bug. -
Re : /makeadmin not working propely. Waird bug. -
Still not working. Also tryed disable the NotAdmin function and the auto-save system. Nothing solve it.......
Re: /makeadmin not working propely. Waird bug. -
I disabled some codes and changed the colors to do it faster, you can change it to whatever you want.. it works fine for me
Re : /makeadmin not working propely. Waird bug. -
Re: /makeadmin not working propely. Waird bug. -
Try it! I hope it works.
Re : /makeadmin not working propely. Waird bug. -
Says me i am not admin even with rcon logged. And the code is suppoosed to be right.. This is driving me crazy. :P
Re: /makeadmin not working propely. Waird bug. -
oh, I had the same issue sometimes with the || on if statement.
Then replace it with this and I am sure it will work.
Re : /makeadmin not working propely. Waird bug. -
Now it work like i had before, as you can see in the picture.. This script is damned or what the fuck happen?
Re: /makeadmin not working propely. Waird bug. -
Actually, that happened on a /v command I had because I return to destroy the car and create the new. After destroyed the vehicle the SERVER: Unknown command appeared and then created the vehicle. After delete the returning in the middle of the script and had it to return a value only at the end it worked fine.
Seriously, ricardo I can't find anything wrong and I can't understand why this happens.