01.10.2011, 21:38
well i use YINI and i use a /SetLevel cmd but it works first time but when i relog my admin is 0 again i dont know how to save it on disconnect as it uses the dcmd params to set the level in the player INI file here is everything i have:
it also seems to be generating some warnings here they are:
the lines are the ones that start with
can someone plz help me on this
pawn Code:
#define FILTERSCRIPT
#include <a_samp>
#include <YSI\y_ini>
#include <sscanf2>
#include <dudb>
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define SendMSG(%0,%1,%2,%3) do{new _str[128]; format(_str,128,%2,%3); SendClientMessage(%0,%1,_str);}while(FALSE) // Credits to ******
#include <a_zones>
#define PATH "/Admin System/Users/%s.ini"
#define PLAYER_MUST_REGISTER
#define REGISTERED_MONEY 5000
#define AUTOLOGIN
#define white 0xFFFFFFA
#define RED 0xE60000AA
#define ABLUE 0x2641FEAA
/* ** Colours ** */
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_WHITE 0xFFFFFFAA
#define color 0xDFF00
#define Red 0xFF0000FF
#define Grey 0xAFAFAFAA
#define Green 0x33AA33AA
#define Yellow 0xFFFF00AA
#define White 0xFFFFFFAA
#define Blue 0x0000BBAA
#define Lightblue 0x33CCFFAA
#define Orange 0xFF9900AA
#define Lime 0x10F441AA
#define Magenta 0xFF00FFF
#define Navy 0x000080AA
#define Aqua 0xF0F8FFAA
#define Crimson 0xDC143CAA
#define Black 0x000000AA
#define Brown 0XA52A2AAA
#define Gold 0xB8860BAA
#define Limegreen 0x32CD32AA
#define Purpley 0x8080FF
#define red 0xFF0000AA
#define lime 0x00FF00FF
#define yellow 0xFFFF00FF
#define DIALOG_REGISTER 999
#define DIALOG_LOGIN 998
#define FormatMSG(%0,%1,%2,%3)\
do{\
format( _S_T_R_, sizeof ( _S_T_R_ ), ( %2 ), %3);\
SendClientMessage( ( %0 ),( %1 ), _S_T_R_);\
}\
while ( False )
#pragma unused ret_memcpy
enum iDetails {
Pass,
Cash,
Score,
AdminLevel,
VIPLevel,
Registered,
Banned
};
new pInfo[MAX_PLAYERS][iDetails];
new _S_T_R_[ 1000 ];
new False=false;
#if defined AUTOLOGIN
new pIP[MAX_PLAYERS][16];
#endif
new pLogged[MAX_PLAYERS];
new pBanned[MAX_PLAYERS];
new pAFK[MAX_PLAYER_NAME];
stock PlayerPath(playerid) {
new iStr[256],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(iStr,sizeof(iStr),PATH,name);
return iStr;
}
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print("Login & Register & Admin System by Bella");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
forward UserDataLoad_data(playerid,name[],value[]);
public UserDataLoad_data(playerid,name[],value[]) {
INI_Int("Pass",pInfo[playerid][Pass]);
#if defined AUTOLOGIN
INI_String("IP",pIP[playerid],16);
#endif
INI_Int("Cash",pInfo[playerid][Cash]);
INI_Int("Score",pInfo[playerid][Score]);
INI_Int("AdminLevel", pInfo[playerid][AdminLevel]);
INI_Int("VIPLevel", pInfo[playerid][VIPLevel]);
INI_Int("Registered", pInfo[playerid][Registered]);
INI_Int("Banned", pInfo[playerid][Banned]);
return 1;
}
public OnPlayerConnect(playerid)
{
pLogged[playerid] = 0;
pAFK[playerid] = 0;
#if defined AUTOLOGIN
new tmpIP[16];
GetPlayerIp(playerid,tmpIP,sizeof(tmpIP));
#endif
if(fexist(PlayerPath(playerid))) {
INI_ParseFile(PlayerPath(playerid), "UserDataLoad_%s", .bExtra = true, .extra = playerid);
#if defined AUTOLOGIN
if(strcmp(tmpIP,pIP[playerid],true) == 0) {
pLogged[playerid] = 1;
SetPlayerScore(playerid,pInfo[playerid][Score]);
GivePlayerMoney(playerid,pInfo[playerid][Cash]);
SendClientMessage(playerid,lime,"You've been auto-logged in. [IP match]");
return 1;
}
#endif
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Please enter your password below.","Login","Leave");
} else {
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please register by entering a password below.","Register","Leave");
}
if(pBanned[playerid] == 1)
{
SendClientMessage(playerid, RED, "You Are Currently Banned from PH Bye Bye");
Kick(playerid);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(pLogged[playerid] == 1) {
new INI:iFile = INI_Open(PlayerPath(playerid));
INI_SetTag(iFile,"data");
INI_WriteInt(iFile,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(iFile,"Score",GetPlayerScore(playerid));
INI_Close(iFile);
}
pLogged[playerid] = 0;
pAFK[playerid] = 0;
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
if(pLogged[playerid] == 0) return SendClientMessage(playerid,yellow,"You must register or login before spawning!");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER) {
GetPlayerIp(playerid,pIP[playerid],16);
if(!response) Kick(playerid);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please enter a password.","Register","Leave");
new INI:iFile = INI_Open(PlayerPath(playerid));
INI_SetTag(iFile,"data");
INI_WriteInt(iFile,"Pass",udb_hash(inputtext));
#if defined AUTOLOGIN
INI_WriteString(iFile,"IP",pIP[playerid]);
#endif
INI_WriteInt(iFile,"Cash",REGISTERED_MONEY);
INI_WriteInt(iFile,"Score",0);
INI_WriteInt(iFile,"AdminLevel",0);
INI_WriteInt(iFile,"VIPLevel",0);
INI_WriteInt(iFile,"Registered",1);
INI_WriteInt(iFile,"Banned",0);
INI_Close(iFile);
pLogged[playerid] = 1;
new iStr[128];
format(iStr,sizeof(iStr),"You've successfully registered with the password \"%s\".",inputtext);
SendClientMessage(playerid,yellow,iStr);
return 1;
}
if(dialogid == DIALOG_LOGIN) {
if(!response) Kick(playerid);
new iStr[128],gTries;
if(gTries == 0) gTries = 1;
if(gTries == 3) {
new pName[30];
GetPlayerName(playerid,pName,sizeof(pName));
format(iStr,sizeof(iStr),"%s has been kicked for exceeding login tries.",pName);
SendClientMessageToAll(red,iStr);
return Kick(playerid);
}
if(!strlen(inputtext)) {
format(iStr,sizeof(iStr),"Please enter your password. Tries: %i/3",gTries);
return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",iStr,"Login","Leave");
}
if(udb_hash(inputtext) == pInfo[playerid][Pass]) {
pLogged[playerid] = 1;
SendClientMessage(playerid,lime,"You've successfully logged in.");
SetPlayerScore(playerid,pInfo[playerid][Score]);
GivePlayerMoney(playerid,pInfo[playerid][Cash]);
} else {
format(iStr,sizeof(iStr),"Incorrect password. Tries: %i/3",gTries);
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register",iStr,"Login","Leave");
gTries++;
return 1;
}
return 1;
}
return 0;
}
//================================================================== [StandardCMDS] ==========================================================//
dcmd_PM(playerid, params[])
{
new id, message, pmstring1[128], pmstring2[128];
if(sscanf(params, "ui", id, message)) return SendClientMessage(playerid, RED,"USAGE:{FFFF00}/PM [playerid] [Message]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED,"ERROR Player Specified is Offline");
if(id == playerid) return SendClientMessage(playerid, RED,"You can't PM yourself"); // Optional
{
format(pmstring1, sizeof(pmstring1),"[PM Message Recived From %s] %s", PlayerName2(playerid), message);
SendClientMessage(id, Yellow, pmstring1);
format(pmstring2, sizeof(pmstring2),"[PM Message Sent To %s] %s", PlayerName2(id), message);
SendClientMessage(playerid, Yellow, pmstring2);
}
return 1;
}
dcmd_Loc(playerid, params[])
{
new id;
if(sscanf(params, "u", id)) return SendClientMessage(playerid, RED, "USAGE:{FFFF00}/loc [id]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED,"ERROR Player Specified is Offline");
if(id == playerid) return SendClientMessage(playerid, RED,"You can't Locate Yourself");
{
new r[128], zone[128];
GetPlayer2DZone(id, zone, sizeof(zone));
format(r, sizeof(r),"Player %s Is in %s", PlayerName2(id), zone);
SendClientMessage(playerid, Yellow, r);
}
return 1;
}
dcmd_AFK(playerid, params[])
{
new string[128], afkreason[50];
if(sscanf(params, "s[128]", afkreason)) return SendClientMessage(playerid, RED,"USAGE:{FFFF00}/afk [Reason]");
if(!strlen(afkreason))
{
format(string, sizeof(string),"%s is not AFK [No Reason Given]", PlayerName2(playerid));
SendClientMessageToAll(Yellow, string);
pAFK[playerid] = 1;
}
else
{
format(string, sizeof(string),"%s is now AFK [Reason: %s]", PlayerName2(playerid), afkreason);
SendClientMessageToAll(Yellow, string);
pAFK[playerid] = 1;
}
return 1;
}
dcmd_Back(playerid, params[])
{
#pragma unused params
new string[128];
format(string, sizeof(string),"%s Is Now Back from being AFK, Welcome Back", PlayerName2(playerid));
SendClientMessageToAll(Yellow, string);
return 1;
}
dcmd_AFKList(playerid, params[])
{
new count = 0;
new string[128];
#pragma unused params
SendClientMessage(playerid, Green, " ");
SendClientMessage(playerid, Green, "___________ |- Current AFK Players -| ___________");
SendClientMessage(playerid, Green, " ");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(pAFK[i] == 1)
{
count++;
GetPlayerName(i, pAFK, sizeof(pAFK));
format(string, sizeof(string), "Current AFK Players: %s", pAFK);
SendClientMessage(playerid, Yellow, string);
SendClientMessage(playerid, Green, " ");
SendClientMessage(playerid, Green, "_____________________________________________");
}
}
}
if(count == 0)
{
SendClientMessage(playerid, Yellow,"No one is AFK here buddy.");
SendClientMessage(playerid, Green, " ");
SendClientMessage(playerid, Green, "_____________________________________________");
SendClientMessage(playerid, Green, " ");
}
return 1;
}
//================================================================== [AdminCMDS] ===========================================================//
dcmd_SetLevel(playerid, params[])
{
if(!pInfo[playerid][AdminLevel] >= 10) return SendClientMessage( playerid, RED, "ERROR: You need to be administrator to use this command!" );
new Player, aLevel;
if(sscanf(params, "ui", Player, aLevel)) return SendClientMessage(playerid, RED,"USAGE: {FFFF00}/SetLevel [PlayerID] [Admin Level]");
if(aLevel > 10 ) return SendClientMessage(playerid, RED, "ERROR: Invalid level! Max admin level you can set is 5!");
if(IsPlayerConnected(Player))
{
new INI:iFile = INI_Open(PlayerPath(playerid));
FormatMSG(Player, ABLUE, "Welcome To The Pilots Heaven Team %s has set your Level to %d", PlayerName2(playerid), aLevel);
FormatMSG(playerid, ABLUE, "You Have Set %s's Admin Level to %d", PlayerName2(Player), aLevel);
INI_SetTag(iFile,"data");
INI_WriteInt(iFile,"AdminLevel",strval(params[1]));
INI_Close(iFile);
}
else return SendClientMessage(playerid, RED,"ERROR Player Specified Not Online!");
return 1;
}
dcmd_SetVIPLevel(playerid, params[])
{
if(!pInfo[playerid][AdminLevel] >= 10) return SendClientMessage( playerid, RED, "ERROR: You need to be administrator to use this command!" );
new Player, vLevel;
if(sscanf(params, "ui", Player, vLevel)) return SendClientMessage(playerid, RED,"USAGE: {FFFF00}/SetVIPLevel [PlayerID] [VIP Level]");
if(vLevel > 10 ) return SendClientMessage(playerid, RED, "ERROR: Invalid level! Max VIP level you can set is 10!");
if(IsPlayerConnected(Player))
{
new INI:iFile = INI_Open(PlayerPath(playerid));
FormatMSG(Player, ABLUE, "Welcome to Pilots Heaven's Elite Band of players also known as VIPS (still in construction so no cmds right now) %s has set you VIP Level to %d", PlayerName2(playerid), vLevel);
FormatMSG(playerid, ABLUE, "You have set %s's level to %d", PlayerName2(Player), vLevel);
INI_SetTag(iFile,"data");
INI_WriteInt(iFile,"VIPLevel",strval(params[1]));
INI_Close(iFile);
}
else return SendClientMessage(playerid, RED,"ERROR Player Specified Not Online!");
return 1;
}
dcmd_Crash(playerid, params[])
{
new string[128], id, reason[50];
if(!pInfo[playerid][AdminLevel] >= 4) return SendClientMessage( playerid, RED, "ERROR: You need to be administrator to use this command!" );
if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, RED,"USAGE: {FFFF00}/Crash [playerid] [reason]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED,"ERROR Player Specified is Offline");
if(id == playerid) return SendClientMessage(playerid, RED,"You can't crash yourself"); // Optional
if(!strlen(reason))
{
format(string, sizeof(string),"%s Has been crashed by Admin %s [no reason given]",PlayerName2(id),PlayerName2(playerid));
SendClientMessageToAll(ABLUE, string);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
}
else
{
format(string, sizeof(string),"%s has been crashed by Admin %s [Reason: %s]",PlayerName2(id), PlayerName2(playerid), reason);
SendClientMessageToAll(ABLUE, string);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
GameTextForPlayer(id, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
}
return 1;
}
dcmd_Ban(playerid, params[])
{
new string[128], id, reason[50];
if(!pInfo[playerid][AdminLevel] >= 4) return SendClientMessage( playerid, RED, "ERROR: You need to be administrator to use this command!" );
if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, RED,"USAGE: {FFFF00}/ban [playerid] [reason]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED,"ERROR Player Specified is Offline");
if(id == playerid) return SendClientMessage(playerid, RED,"You can't ban yourself"); // Optional
if(!strlen(reason))
{
new INI:iFile = INI_Open(PlayerPath(playerid));
format(string, sizeof(string),"%s Has been Banned by Admin %s [no reason given]",PlayerName2(id),PlayerName2(playerid));
SendClientMessageToAll(ABLUE, string);
INI_SetTag(iFile,"data");
INI_WriteInt(iFile,"Banned", 1);
INI_Close(iFile);
pBanned[id] = 1;
Kick(id);
}
else
{
new INI:iFile = INI_Open(PlayerPath(playerid));
format(string, sizeof(string),"%s has been Banned by Admin %s [Reason: %s]",PlayerName2(id), PlayerName2(playerid), reason);
SendClientMessageToAll(ABLUE, string);
INI_SetTag(iFile,"data");
INI_WriteInt(iFile,"Banned", 1);
INI_Close(iFile);
pBanned[id] = 1;
Kick(id);
}
return 1;
}
dcmd_Announce(playerid, params[])
{
new Message[128];
if(!pInfo[playerid][AdminLevel] >= 1) return SendClientMessage( playerid, RED, "ERROR: You need to be administrator to use this command!" );
if(sscanf(params, "s[128]", Message)) return SendClientMessage( playerid, RED, "USAGE: {FFFF00}/announce [Message]" );
{
GameTextForAll(Message, 6000, 4);
}
return 1;
}
dcmd_Kick(playerid, params[])
{
new string[128], id, reason[50];
if(!pInfo[playerid][AdminLevel] >= 4) return SendClientMessage( playerid, RED, "ERROR: You need to be administrator to use this command!" );
if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, RED,"USAGE: {FFFF00}/Kick [playerid] [reason]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED,"ERROR Player Specified is Offline");
if(id == playerid) return SendClientMessage(playerid, RED,"You can't ban yourself"); // Optional
if(!strlen(reason))
{
format(string, sizeof(string),"%s Has been kicked by Admin %s [no reason given]",PlayerName2(id),PlayerName2(playerid));
SendClientMessageToAll(ABLUE, string);
Kick(id);
}
else
{
format(string, sizeof(string),"%s Has been kicked by Admin %s [Reason: %s]",PlayerName2(id),PlayerName2(playerid), reason);
SendClientMessageToAll(ABLUE, string);
Kick(id);
}
return 1;
}
//================================================================== [ STOCKS ] ===========================================================//
stock PlayerName2( i )
{
new n[ 24 ];
GetPlayerName( i, n, 24 );
return n;
}
forward GetPlayerAVSAdmin(playerid);
public GetPlayerAVSAdmin(playerid)
{
return pInfo[playerid][AdminLevel];
}
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(PM, 2, cmdtext);
dcmd(Loc, 3, cmdtext);
dcmd(AFK, 3, cmdtext);
dcmd(Back, 4, cmdtext);
dcmd(AFKList, 7, cmdtext);
dcmd(SetLevel, 8, cmdtext);
dcmd(SetVIPLevel, 11, cmdtext);
dcmd(Crash, 5, cmdtext);
dcmd(Ban, 3, cmdtext);
dcmd(Announce, 8, cmdtext);
dcmd(Kick, 4, cmdtext);
return 0;
}
Code:
C:\DOCUME~1\Rhys\Desktop\SA8BEC~1\FILTER~1\Account.pwn(325) : warning 213: tag mismatch C:\DOCUME~1\Rhys\Desktop\SA8BEC~1\FILTER~1\Account.pwn(344) : warning 213: tag mismatch C:\DOCUME~1\Rhys\Desktop\SA8BEC~1\FILTER~1\Account.pwn(364) : warning 213: tag mismatch C:\DOCUME~1\Rhys\Desktop\SA8BEC~1\FILTER~1\Account.pwn(397) : warning 213: tag mismatch C:\DOCUME~1\Rhys\Desktop\SA8BEC~1\FILTER~1\Account.pwn(428) : warning 213: tag mismatch C:\DOCUME~1\Rhys\Desktop\SA8BEC~1\FILTER~1\Account.pwn(438) : warning 213: tag mismatch Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 6 Warnings.
Code:
!pInfo[playerid][AdminLevel]