PDA

View Full Version : /makeadmin problem


GabiXx
01/08/2015, 06:24 PM
I make this.
CMD:makeadmin(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You have no acces to this command.");
new PID;
new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
new string[128]
if(sscanf(params, "u", PID,pAdmin)) return SendClientMessage(playerid, 0xFFFF00, "/makeadmin [playerid] [adminlevel]");
GetPlayerName(PID, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));
PlayerInfo[PID][pAdmin] = level;
format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
SendClientMessage(giveplayerid, 0xFFFF00, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[PID][pAdmin]);
SendClientMessage(playerid, 0xFFFF00, string);
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, 0xFF0000FF, "This player isn't online."
return 1;
}
Have this.
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}
When compile get warning 203: symbol is never used: "makeadmin"

Mariciuc223
01/08/2015, 06:26 PM
you put somewhere in your script "new makeadmin"

find that line and delete it :)

GabiXx
01/08/2015, 06:30 PM
#include <a_samp>
#include <YSI\y_ini>

#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4

#define PATH "/Users/%s.ini"

#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"

enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
return 1;
}

stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playernam e));
format(string,sizeof(string),PATH,playername);
return string;
}

/*Credits to Dracoblue*/
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}

main()
{
print("\n----------------------------------");
print(" In regia lui GoguXx ");
print("----------------------------------\n");
}

public OnGameModeInit()
{
SetGameModeText("RPG v69");
AddStaticVehicle(522,1226.5582,-1867.9752,13.5469,1.1376, 006,000);
return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
return 1;
}

public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
new
szString[64],
playerName[MAX_PLAYER_NAME];

GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);

new szDisconnectReason[3][] =
{
"Timeout/Crash",
"Quit",
"Kick/Ban"
};

format(szString, sizeof szString, "%s left the server (%s).", playerName, szDisconnectReason[reason]);

SendClientMessageToAll(0xC4C4C4FF, szString);
return 1;
}

public OnPlayerSpawn(playerid)
{
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
SetSpawnInfo(playerid, 0, 0, 1214.8846,-1821.6281,13.5943,179.1360, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}

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[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);

SetSpawnInfo(playerid, 0, 0, 1214.8846,-1821.6281,13.5943,179.1360, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Distractie placuta! Have fun!","Ok","");
}
}

case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Distractie placuta! Have fun!","Ok","");
SetSpawnInfo(playerid, 0, 0, 1214.8846,-1821.6281,13.5943,179.1360, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}

public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
if(IsPlayerAdmin(playerid))
{
SetPlayerPosFindZ(playerid, fX, fY, fZ);
}
return 1;
}

CMD:makeadmin(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You have no acces to this command.");
new PID;
new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
new string[128]
if(sscanf(params, "u", PID,pAdmin)) return SendClientMessage(playerid, 0xFFFF00, "/makeadmin [playerid] [adminlevel]");
GetPlayerName(PID, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));
PlayerInfo[PID][pAdmin] = level;
format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
SendClientMessage(giveplayerid, 0xFFFF00, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[PID][pAdmin]);
SendClientMessage(playerid, 0xFFFF00, string);
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, 0xFF0000FF, "This player isn't online."
return 1;
}
I still don't find it.

Mariciuc223
01/08/2015, 06:31 PM
#include <a_samp>
#include <YSI\y_ini>

#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4

#define PATH "/Users/%s.ini"

#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"

enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
return 1;
}

stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playernam e));
format(string,sizeof(string),PATH,playername);
return string;
}

/*Credits to Dracoblue*/
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}

main()
{
print("\n----------------------------------");
print(" In regia lui GoguXx ");
print("----------------------------------\n");
}

public OnGameModeInit()
{
SetGameModeText("RPG v69");
AddStaticVehicle(522,1226.5582,-1867.9752,13.5469,1.1376, 006,000);
return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
return 1;
}

public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
new
szString[64],
playerName[MAX_PLAYER_NAME];

GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);

new szDisconnectReason[3][] =
{
"Timeout/Crash",
"Quit",
"Kick/Ban"
};

format(szString, sizeof szString, "%s left the server (%s).", playerName, szDisconnectReason[reason]);

SendClientMessageToAll(0xC4C4C4FF, szString);
return 1;
}

public OnPlayerSpawn(playerid)
{
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
SetSpawnInfo(playerid, 0, 0, 1214.8846,-1821.6281,13.5943,179.1360, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}

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[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);

SetSpawnInfo(playerid, 0, 0, 1214.8846,-1821.6281,13.5943,179.1360, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Distractie placuta! Have fun!","Ok","");
}
}

case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Distractie placuta! Have fun!","Ok","");
SetSpawnInfo(playerid, 0, 0, 1214.8846,-1821.6281,13.5943,179.1360, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}

public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
if(IsPlayerAdmin(playerid))
{
SetPlayerPosFindZ(playerid, fX, fY, fZ);
}
return 1;
}

CMD:makeadmin(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You have no acces to this command.");
new PID;
new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
new string[128]
if(sscanf(params, "u", PID,pAdmin)) return SendClientMessage(playerid, 0xFFFF00, "/makeadmin [playerid] [adminlevel]");
GetPlayerName(PID, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));
PlayerInfo[PID][pAdmin] = level;
format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
SendClientMessage(giveplayerid, 0xFFFF00, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[PID][pAdmin]);
SendClientMessage(playerid, 0xFFFF00, string);
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, 0xFF0000FF, "This player isn't online."
return 1;
}
I still don't find it.

lol , include <ZCMD> :P

P.S: http://forum.sa-mp.com/showthread.php?t=91354

whatreally
01/08/2015, 06:34 PM
CMD:makeadmin(playerid, params[])
{
if(PlayerInfo[PID][pAdmin] >= 5 || IsPlayerAdmin(playerid))
{
new PID;
new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
new string[128]
if(sscanf(params, "u", PID,pAdmin)) return SendClientMessage(playerid, 0xFFFF00, "/makeadmin [playerid] [adminlevel]");
GetPlayerName(PID, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));
PlayerInfo[PID][pAdmin] = level;
format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
SendClientMessage(giveplayerid, 0xFFFF00, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[PID][pAdmin]);
SendClientMessage(playerid, 0xFFFF00, string);
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, 0xFF0000FF, "This player isn't online."
return 1;
}

Mariciuc223
01/08/2015, 06:36 PM
CMD:makeadmin(playerid, params[])
{
if(PlayerInfo[PID][pAdmin] >= 5 || IsPlayerAdmin(playerid))
{
new PID;
new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
new string[128]
if(sscanf(params, "u", PID,pAdmin)) return SendClientMessage(playerid, 0xFFFF00, "/makeadmin [playerid] [adminlevel]");
GetPlayerName(PID, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));
PlayerInfo[PID][pAdmin] = level;
format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
SendClientMessage(giveplayerid, 0xFFFF00, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[PID][pAdmin]);
SendClientMessage(playerid, 0xFFFF00, string);
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, 0xFF0000FF, "This player isn't online."
return 1;
}

Dude , you missed a bracket + he dosen't included ZCMD ...

Mariciuc223
01/08/2015, 06:44 PM
#include <a_samp>
#include <YSI\y_ini>
#include <ZCMD>
#include <sscanf>

#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4

#define PATH "/Users/%s.ini"

#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"

enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
return 1;
}

stock UserPath(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playernam e));
format(string,sizeof(string),PATH,playername);
return string;
}

/*Credits to Dracoblue*/
stock udb_hash(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}

main()
{
print("\n----------------------------------");
print(" In regia lui GoguXx ");
print("----------------------------------\n");
}

public OnGameModeInit()
{
SetGameModeText("RPG v69");
AddStaticVehicle(522,1226.5582,-1867.9752,13.5469,1.1376, 006,000);
return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
return 1;
}

public OnPlayerConnect(playerid)
{
if(fexist(UserPath(playerid)))
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
new
szString[64],
playerName[MAX_PLAYER_NAME];

GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);

new szDisconnectReason[3][] =
{
"Timeout/Crash",
"Quit",
"Kick/Ban"
};

format(szString, sizeof szString, "%s left the server (%s).", playerName, szDisconnectReason[reason]);

SendClientMessageToAll(0xC4C4C4FF, szString);
return 1;
}

public OnPlayerSpawn(playerid)
{
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
SetSpawnInfo(playerid, 0, 0, 1214.8846,-1821.6281,13.5943,179.1360, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}

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[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);

SetSpawnInfo(playerid, 0, 0, 1214.8846,-1821.6281,13.5943,179.1360, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Distractie placuta! Have fun!","Ok","");
}
}

case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Distractie placuta! Have fun!","Ok","");
SetSpawnInfo(playerid, 0, 0, 1214.8846,-1821.6281,13.5943,179.1360, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}

public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
if(IsPlayerAdmin(playerid))
{
SetPlayerPosFindZ(playerid, fX, fY, fZ);
}
return 1;
}

CMD:makeadmin(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 5 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: {FFFFFF} You need to be admin level 5 or higher !");

new id, level;
new pName[MAX_PLAYER_NAME], aName[MAX_PLAYER_NAME];
new String[128];

if(sscanf(params, "ui", id, level)) return SendClientMessage(playerid, 0xFFFF00, "USAGE: /makeadmin [PlayerID/PartOfName][AdminLevel]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFF00, "ERROR: {FFFFFF}That player it's not connected !");

GetPlayerName(id, pName, sizeof(pName));
GetPlayerName(playerid, aName, sizeof(aName));

PlayerInfo[id][pAdmin] = level;

format(String, sizeof(String), "You are now an administrator level %d thanks to %s.", level, aName);
SendClientMessage(id, 0xFFFF00, String);

format(String, sizeof(String), "You have given %s level %d admin.", pName, level);
SendClientMessage(playerid, 0xFFFF00, String);

return 1;
}

There it's the code fixed ...

GabiXx
01/08/2015, 06:45 PM
Yea, you right.
CMD:makeadmin(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You have no acces to this command.");
new PID;
new level;
new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
new string[128]
if(sscanf(params, "us[64]", PID,pAdmin)) return SendClientMessage(playerid, 0xFFFF00, "/makeadmin [playerid] [adminlevel]");
GetPlayerName(PID, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));
PlayerInfo[PID][pAdmin] = level;
format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
SendClientMessage(PID, 0xFFFF00, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[PID][pAdmin]);
SendClientMessage(playerid, 0xFFFF00, string);
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, 0xFF0000FF, "This player isn't online.");
return 1;
}
Now i get this at line with if(sscanf....."
error 001: expected token: ";", but found "if"

Mariciuc223
01/08/2015, 06:46 PM
Yea, you right.
CMD:makeadmin(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You have no acces to this command.");
new PID;
new level;
new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
new string[128]
if(sscanf(params, "us[64]", PID,pAdmin)) return SendClientMessage(playerid, 0xFFFF00, "/makeadmin [playerid] [adminlevel]");
GetPlayerName(PID, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));
PlayerInfo[PID][pAdmin] = level;
format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
SendClientMessage(PID, 0xFFFF00, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[PID][pAdmin]);
SendClientMessage(playerid, 0xFFFF00, string);
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, 0xFF0000FF, "This player isn't online.");
return 1;
}
Now i get this at line with if(sscanf....."
error 001: expected token: ";", but found "if"

new string[128]

there you missed ';'

new string[128];

Check above , i put fixed CMD ..

GabiXx
01/08/2015, 06:53 PM
When i try use /makeadmin 1,2,3,4, the message show player get admin level 0.

gurmani11
01/08/2015, 06:54 PM
add include sscanf

http://forum.sa-mp.com/showthread.php?t=570927

Mariciuc223
01/08/2015, 07:03 PM
Use my code , i just tested and it's work (put an if like that if(level > 5) return 1; -> will return if you want to give an admin level higher than 5)

GabiXx
01/08/2015, 09:27 PM
I put that, same problem.
I try /makeadmin 1 1, and see player get admin 0.

xVIP3Rx
01/08/2015, 10:03 PM
Here you go.

CMD:makeadmin(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You have no acces to this command.");

new PID, level;
if(sscanf(params, "ui", PID,level)) return SendClientMessage(playerid, 0xFFFF00, "/makeadmin [playerid] [adminlevel]");
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, 0xFF0000FF, "This player isn't online.");

new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
GetPlayerName(PID, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));

PlayerInfo[PID][pAdmin] = level;

new string[128];
format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
SendClientMessage(PID, 0xFFFF00, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[PID][pAdmin]);
SendClientMessage(playerid, 0xFFFF00, string);
return 1;
}

GabiXx
01/08/2015, 11:31 PM
Ty, but can you make this with max level 5 admin?

xVIP3Rx
02/08/2015, 01:26 AM
CMD:makeadmin(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You have no acces to this command.");

new PID, level;
if(sscanf(params, "ui", PID,level)) return SendClientMessage(playerid, 0xFFFF00, "/makeadmin [playerid] [adminlevel]");
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, 0xFF0000FF, "This player isn't online.");
if(level > 5 || level < 0) return SendClientMessage(playerid, 0xFF0000FF, "Maximum admin level is 5.");

new player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
GetPlayerName(PID, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, player, sizeof(player));

PlayerInfo[PID][pAdmin] = level;

new string[128];
format(string, sizeof(string), "You are now an administrator level %d thanks to %s.", level, player);
SendClientMessage(PID, 0xFFFF00, string);
format(string, sizeof(string), "You have given %s level %d admin.", giveplayer,PlayerInfo[PID][pAdmin]);
SendClientMessage(playerid, 0xFFFF00, string);
return 1;
}