[Help]administration script
#1

hi, i tried to make a simple administraion script but i had some errors... plz help me ( sorry for my bad english )
PHP код:
#include <a_samp>
#include <dini>
#include <dutils>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define COLOUR_GREEN           0x33AA33AA
#define COLOUR_RED             0xAA3333AA
#define COLOUR_YELLOW          0xFFFF00AA
#define COLOUR_LIGHTBLUE       0x33CCFFAA
#define COLOUR_ORANGE          0xFF9900AA
#define PlayerFile            "Administraionscript/Users/%s.ini"
#define SettingFile            "Administrationscript/Settings/MainSettings.ini"
#define CommandFile            "Administrationscript/Settings/Commands.ini"
    
enum PLAYER_MAIN {
    
PLAYER_NAME[MAX_PLAYER_NAME],
    
PLAYER_IP[16],
    
PLAYER_REGGED,
    
PLAYER_PASS,
    
PLAYER_LOGGED,
    
PLAYER_LEVEL,
    
PLAYER_WIRED,
    
PLAYER_JAILED
}
enum COMMANDS_MAIN {
    
AKILL,
    
ANNOUNCE,
    
ARMOURALL,
    
BAN,
    
CARHP,
    
EXPLODE,
    
FLIP,
    GOTO,
    
GETHERE,
    
GIVEARMOUR,
    
GIVEHEALTH,
    
GIVEWEAPON,
    
GOD,
    
HEALALL,
    
IMITATE,
    
IP,
    
KICK,
    
MAXAMMO,
    
PING,
    
SETLEVEL,
    
SETWANTED,
    
TBAN,
    
TIME,
    
WEATHER
}
enum SETTINGS_MAIN {
    
POCKET_MONEY,
    
JAIL_COMMANDS,
    
ANNOUNCE_SECONDS,
    
PASS_MIN,
    
PASS_MAX
}
new 
gCommands[COMMANDS_MAIN];
new 
gPlayerInfo[MAX_PLAYERS][PLAYER_MAIN];
new 
gSettings[SETTINGS_MAIN];
public 
OnFilterScriptInit()
{
     print(
"\n****************************************");
    print(
"* Admin Filterscript by your name here *");
    print(
"****************************************\n");
        if(!
fexist(SettingFile))
    {
        
dini_Create(SettingFile);
        
dini_IntSet(SettingFile"PocketMoney"3000);
        
dini_IntSet(SettingFile"JailCommands"0);
        
dini_IntSet(SettingFile"AnnounceSeconds"3);
        
dini_IntSet(SettingFile"PassMin"3);
        
dini_IntSet(SettingFile"PassMax"15);
    }
    
gSettings[POCKET_MONEY]         = dini_Int(SettingFile"PocketMoney");
    
gSettings[JAIL_COMMANDS]         = dini_Int(SettingFile"JailCommands");
    
gSettings[ANNOUNCE_SECONDS]             = dini_Int(SettingFile"AnnounceSeconds");
    
gSettings[PASS_MIN]             = dini_Int(SettingFile"PassMin");
    
gSettings[PASS_MAX]             = dini_Int(SettingFile"PassMax");
    if(!
fexist(CommandFile))
    {
        
dini_Create(CommandFile);
        
dini_IntSet(CommandFile"Akill"6);
        
dini_IntSet(CommandFile"Announce"5);
        
dini_IntSet(CommandFile"Armourall"3);
        
dini_IntSet(CommandFile"Ban"9);
        
dini_IntSet(CommandFile"Carhp"4);
        
dini_IntSet(CommandFile"Explode"5);
        
dini_IntSet(CommandFile"Goto"4);
        
dini_IntSet(CommandFile"Gethere"5);
        
dini_IntSet(CommandFile"Givearmour"6);
        
dini_IntSet(CommandFile"Givehealth"6);
        
dini_IntSet(CommandFile"Giveweapon"7);
        
dini_IntSet(CommandFile"God"10);
        
dini_IntSet(CommandFile"Healall"7);
        
dini_IntSet(CommandFile"Imitate"8);
        
dini_IntSet(CommandFile"Ip"2);
        
dini_IntSet(CommandFile"Kick"7);
        
dini_IntSet(CommandFile"Maxammo"8);
        
dini_IntSet(CommandFile"Ping"1);
        
dini_IntSet(CommandFile"Setlevel"10);
        
dini_IntSet(CommandFile"Setwanted"6);
        
dini_IntSet(CommandFile"Tban"9);
        
dini_IntSet(CommandFile"Time"3);
        
dini_IntSet(CommandFile"Weather"3);
        }
    
gCommands[AKILL]             = dini_Int(CommandFile"Akill");
    
gCommands[ANNOUNCE]                 = dini_Int(CommandFile"Announce");
    
gCommands[ARMOURALL]             = dini_Int(CommandFile"Armourall");
    
gCommands[BAN]                 = dini_Int(CommandFile"Ban");
    
gCommands[CARHP]             = dini_Int(CommandFile"Carhp");
    
gCommands[EXPLODE]             = dini_Int(CommandFile"Explode");
    
gCommands[GOTO]             = dini_Int(CommandFile"Goto");
    
gCommands[GETHERE]             = dini_Int(CommandFile"Gethere");
    
gCommands[GIVEARMOUR]             = dini_Int(CommandFile"Givearmour");
    
gCommands[GIVEHEALTH]             = dini_Int(CommandFile"Givehealth");
    
gCommands[GIVEWEAPON]             = dini_Int(CommandFile"Giveweapon");
    
gCommands[GOD]                 = dini_Int(CommandFile"God");
    
gCommands[HEALALL]             = dini_Int(CommandFile"Healall");
    
gCommands[IMITATE]             = dini_Int(CommandFile"Imitate");
    
gCommands[IP]                 = dini_Int(CommandFile"Ip");
    
gCommands[KICK]             = dini_Int(CommandFile"Kick");
    
gCommands[MAXAMMO]             = dini_Int(CommandFile"Maxammo");
    
gCommands[SETLEVEL]             = dini_Int(CommandFile"Setlevel");
    
gCommands[SETWANTED]             = dini_Int(CommandFile"Setwanted");
    
gCommands[TBAN]             = dini_Int(CommandFile"Tban");
    
gCommands[TIME]             = dini_Int(CommandFile"Time");
    
gCommands[WEATHER]             = dini_Int(CommandFile"Weather");
     return 
1;
}
   
#endif
public OnPlayerConnect(playerid)
{
     new 
file[100],Name[MAX_PLAYER_NAME],Ip[16];
        
GetPlayerName(playerid,Name,sizeof(Name));
        
GetPlayerIp(playerid,Ip,sizeof(Ip));
        
format(file,sizeof(file),PlayerFile,Name);
    if(!
dini_Exists(file))
        {
         
dini_Create(file);
         
dini_Set(file,"Name",Name);
         
dini_Set(file,"Ip",Ip);
         
dini_IntSet(file,"Registered",-1);
         
dini_IntSet(file,"Password",0);
         
dini_IntSet(file,"Level",0);
         
dini_IntSet(file,"Wired",0);
         
dini_IntSet(file,"Jailed",0);
         
SendClientMessage(playerid,COLOUR_ORANGE,"Your username is not recognized on this server. Please /register to continue.");
    }
    
strcat(gPlayerInfo[playerid][PLAYER_NAME],            dini_Get(file,"Name"));
    
strcat(gPlayerInfo[playerid][PLAYER_IP],            dini_Get(file,"Ip"));
    
gPlayerInfo[playerid][PLAYER_REGGED]                   = dini_Int(file,"Registered");
    
gPlayerInfo[playerid][PLAYER_PASS]                            = dini_Int(file,"Password");
    
gPlayerInfo[playerid][PLAYER_LEVEL]                   = dini_Int(file,"Level");
    
gPlayerInfo[playerid][PLAYER_WIRED]                           = dini_Int(file,"Wired");
    
gPlayerInfo[playerid][PLAYER_JAILED]                   = dini_Int(file,"Jailed");
    if(
gPlayerInfo[playerid][PLAYER_REGGED] == 0)                     SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server, but you have not registered. Please /register to continue.");
    else if(
gPlayerInfo[playerid][PLAYER_REGGED] == 1)              SendClientMessage(playerid,COLOUR_ORANGE,"You're username is recognised on this server. Please /login to continue.");
        
gPlayerInfo[playerid][PLAYER_REGGED]                          = 0;
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    new 
file[100];
        
format(file,sizeof(file),PlayerFile,gPlayerInfo[playerid][PLAYER_NAME]);
    
dini_Set(file,"Name",gPlayerInfo[playerid][PLAYER_NAME]);
    
dini_Set(file,"Ip",gPlayerInfo[playerid][PLAYER_IP]);
    
dini_IntSet(file,"Registered",gPlayerInfo[playerid][PLAYER_REGGED]);
    
dini_IntSet(file,"Password",gPlayerInfo[playerid][PLAYER_PASS]);
    
dini_IntSet(file,"Level",gPlayerInfo[playerid][PLAYER_LEVEL]);
    
dini_IntSet(file,"Wired",gPlayerInfo[playerid][PLAYER_WIRED]);
    
dini_IntSet(file,"Jailed",gPlayerInfo[playerid][PLAYER_JAILED]);
    
gPlayerInfo[playerid][PLAYER_NAME]   = 0;
    
gPlayerInfo[playerid][PLAYER_IP]     = 0;
    
gPlayerInfo[playerid][PLAYER_REGGED] = 0;
    
gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
    
gPlayerInfo[playerid][PLAYER_PASS]   = 0;
    
gPlayerInfo[playerid][PLAYER_LEVEL]  = 0;
    
gPlayerInfo[playerid][PLAYER_WIRED]  = 0;
    
gPlayerInfo[playerid][PLAYER_JAILED] = 0;
        return 
1;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    
dcmd(register8cmdtext);
    
dcmd(login5cmdtext);
    
dcmd(logout6cmdtext);
    
dcmd(password8cmdtext);
    return 
0;
}
dcmd_register(playeridparams[])
{
    if(
gPlayerInfo[playerid][PLAYER_REGGED] == 1)
    return 
SendClientMessage(playeridCOLOUR_ORANGE"ERROR: You have already registered!");
    else if(!
params[0])
    return 
SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /register [password]");
    else if(
strlen(params) < gSettings[PASS_MIN] || strlen(params) > gSettings[PASS_MAX])
    {
    new 
string[128];
        
format(stringsizeof(string), "ERROR: Password must be between %d and $d characters long!"gSettings[PASS_MIN], gSettings[PASS_MAX]);
    return 
SendClientMessage(playeridCOLOUR_ORANGEstring);
    }
    else
    {
    new 
password num_hash(params);
    
gPlayerInfo[playerid][PLAYER_PASS] = password;
    
gPlayerInfo[playerid][PLAYER_REGGED] = 1;
        
gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
    
GetPlayerIp(playeridgPlayerInfo[playerid][PLAYER_IP], 16);
    new 
string[128]; format(stringsizeof(string), "You have successfully registered your account with the password \'%s\'. You have been automatically logged in."params);
    return 
SendClientMessage(playeridCOLOUR_LIGHTBLUEstring);
    }
}
dcmd_login(playeridparams[])
{
    if(
gPlayerInfo[playerid][PLAYER_REGGED] != 1)
    return 
SendClientMessage(playeridCOLOUR_ORANGE"ERROR: You must register first to do that! Use /register [password] to register and login.");
    else if(
gPlayerInfo[playerid][PLAYER_LOGGED] == 1)
    return 
SendClientMessage(playeridCOLOUR_ORANGE"ERROR: You are already logged-in.");
    else if(!
params[0])
    return 
SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /login [password]");
    else
    {
    new 
password num_hash(params);
    if(
gPlayerInfo[playerid][PLAYER_PASS] == password)
    {
        
gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
            
GetPlayerIp(playeridgPlayerInfo[playerid][PLAYER_IP], 16);
        return 
SendClientMessage(playeridCOLOUR_LIGHTBLUE"You have successfully logged in to your account.");
    }
    else
        return 
SendClientMessage(playeridCOLOUR_ORANGE"ERROR: Incorrect password.");
    }
}
dcmd_logout(playeridparams[])
{
#pragma unused params
    
if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
    return 
SendClientMessage(playeridCOLOUR_ORANGE"ERROR: You must register first to do that! Use /register [password] to register.");
    else if(
gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
    return 
SendClientMessage(playeridCOLOUR_ORANGE"ERROR: You are already logged-out.");
    else
    {
    
gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
    return 
SendClientMessage(playeridCOLOUR_LIGHTBLUE"You have successfully logged out of your account.");
    }
}
dcmd_password(playeridparams[])
{
    if(
gPlayerInfo[playerid][PLAYER_REGGED] != 1)
        return 
SendClientMessage(playeridCOLOUR_ORANGE"ERROR: You must register first to do that! Use /register [password] to register and login.");
    else if(
gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
    return 
SendClientMessage(playeridCOLOUR_ORANGE"ERROR: You must be logged-in to do that! Use /login [password] to login.");
    else
    {
    new 
tmp[30],
        
tmp2[30],
        
index;
    
tmp strtok(paramsindex);
    if(!
strlen(tmp))
            return 
SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /password [password] [new password]");
    
tmp2 strtok(paramsindex);
    if(!
strlen(tmp2))
        return 
SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /password [password] [new password]");
        new 
oldpassword num_hash(tmp), newpassword num_hash(tmp2);
    if(
gPlayerInfo[playerid][PLAYER_PASS] == oldpassword)
    {
        if(
oldpassword == newpassword)
            return 
SendClientMessage(playeridCOLOUR_ORANGE"ERROR: Your old password can not be the same as your new password.");
            else if(
strlen(tmp2) < gSettings[PASS_MIN] || strlen(tmp2) > gSettings[PASS_MAX])
            {
                new 
string[100]; format(stringsizeof(string), "ERROR: Your new password must be between %d and %d characters long!"gSettings[PASS_MIN], gSettings[PASS_MAX]);
                return 
SendClientMessage(playeridCOLOUR_ORANGEstring);
            }
        
gPlayerInfo[playerid][PLAYER_PASS] = newpassword;
        new 
string[128]; format(stringsizeof(string), "You have successfully changed your password from \'%s\' to \'%s\'."tmptmp2);
        return 
SendClientMessage(playeridCOLOUR_LIGHTBLUEstring);
    }
    else
        return 
SendClientMessage(playeridCOLOUR_ORANGE"ERROR: Incorrect password.");
    }
}
dcmd_akill(playeridparams[])
{
    if(
gPlayerInfo[playerid][PLAYER_LEVEL] < gCommands[AKILL])
    {
        new 
string[100];
        
format(stringsizeof(string), "You must be administrator level %d to use that command!"gCommands[AKILL]);
        return 
SendClientMessage(playeridCOLOUR_ORANGEstring);
    }
    else if(!
strlen(params))
        return 
SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /akill [id | name]");
    else
    {
    new 
id = (isNumeric(params)) ? strval(params) : GetPlayerId(params);
    if(
IsPlayerConnected(id) && id != playerid)
    {
        
SetPlayerHealth(id0.0);
        new 
string[128];
        
format(stringsizeof(string), "You have been admin-killed by administrator \'%s\'."gPlayerInfo[playerid][PLAYER_NAME]);
        
SendClientMessage(idCOLOUR_ORANGEstring);
        
format(stringsizeof(string), "You have successfully admin-killed player \'%s\'."gPlayerInfo[id][PLAYER_NAME]);
        return 
SendClientMessage(playeridCOLOUR_LIGHTBLUEstring);
    }
    else
        return 
SendClientMessage(playeridCOLOUR_ORANGE"ERROR: You can not admin-kill yourself or a disconnected player.");
    }
}
dcmd_announce(playeridparams[])
{
    if(
gPlayerInfo[playerid][PLAYER_LEVEL] < gCommands[ANNOUNCE])
    {
        new 
string[100];
        
format(stringsizeof(string), "You must be administrator level %d to use that command!"gCommands[ANNOUNCE]);
        return 
SendClientMessage(playeridCOLOUR_ORANGEstring);
    }
    else if(!
strlen(params))
        return 
SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /announce [message]");
    else
        return 
GameTextForAll(paramsgSettings[ANNOUNCE_SECONDS] * 10003);

those are my errors: ( if you can try to tell me how to remove my warning too...)
PHP код:
D:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(71) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(81) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(146) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(150) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(171) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(172) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(178) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(179) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(194) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(216) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(217) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(224) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(225) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(245) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(246) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(278) : error 047: array sizes do not match, or destination array is too small
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(281) : error 047: array sizes do not match, or destination array is too small
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(284) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(285) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(347) : warning 203symbol is never used"dcmd_akill"
D:\gta san andreas online\Godfucker\filterscripts\TGFadmin.pwn(347) : warning 203symbol is never used"dcmd_announce"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
2 Errors

Reply
#2

new tmp[30],
tmp2[30],

--->>

new tmp[255],
tmp2[255],

don't think it's professional help you're getting here
Reply
#3

thx it works!!! i am just a begginer so i didnt know what to do... can you explain what the difference between
--------------------------------------------------------------------------------

new tmp[30],
tmp2[30],

--->>

new tmp[255],
tmp2[255],
thx
Reply
#4

https://sampwiki.blast.hk/wiki/Scripting_Basics#Strings
Reply
#5

So happy, lol.
Reply
#6

And also, 255 is too big. The max cells of a single line in clientmessage is 128.
Reply
#7

smaller produces errors, care to continue? (kinda explains the
Quote:

don't think it's professional help you're getting here

)
Reply
#8

https://sampforum.blast.hk/showthread.php?tid=55261
255 is just as bad as 256.
Reply
#9

yes I am aware of that.... care to come with another solution then?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)