SA-MP Forums Archive
[HELP]admin script - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]admin script (/showthread.php?tid=224264)



[HELP]admin script - omer5198 - 11.02.2011

PHP код:
#pragma unused ret_memcpy
#include <a_samp>
#include <dini>
#include <dudb>
#include <returnuser>
#define COLOUR_YELLOW 0xFFFF00AA
#define COLOUR_RED 0xFF0000AA
#define COLOUR_RED 0xFF0000AA
#define COLOUR_ORANGE 0xFF9900AA
enum pInfo
{
    
pAdminLevel,
    
pCash,
    
pScore,
}
new 
PlayerInfo[MAX_PLAYERS][pInfo];
new 
gPlayerLogged[MAX_PLAYERS];
#define SERVER_USER_FILE "Register_Dialog/Users/%s.ini"
public OnPlayerConnect(playerid)
{
    
gPlayerLogged[playerid] = 0;
    
PlayerInfo[playerid][pAdminLevel] = 0;
    new 
name[MAX_PLAYER_NAME], file[256];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), SERVER_USER_FILEname);
    if (!
dini_Exists(file))
    {
        
ShowPlayerDialog(playerid1DIALOG_STYLE_INPUT"Hi you are not registered""Welcome, you are not registered. to register please input your registration password below""Register""Leave");
    }
    if(
fexist(file))
    {
        
ShowPlayerDialog(playerid2DIALOG_STYLE_INPUT"Hi you are registered""you are already registered. to login please Inpute your password below""Login""Leave");
    }
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    new 
name[MAX_PLAYER_NAME], file[256];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), SERVER_USER_FILEname);
    if(
gPlayerLogged[playerid] == 1)
    {
        
dini_IntSet(file"Score"PlayerInfo[playerid][pScore]);
        
dini_IntSet(file"Money"PlayerInfo[playerid][pCash]);
        
dini_IntSet(file"AdminLevel",PlayerInfo[playerid][pAdminLevel]);
    }
    
gPlayerLogged[playerid] = 0;
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if (
dialogid == 1)
    {
        new 
name[MAX_PLAYER_NAME], file[256], string[128];
        
GetPlayerName(playeridnamesizeof(name));
        
format(filesizeof(file), SERVER_USER_FILEname);
        if(!
response) return Kick(playerid);
        if (!
strlen(inputtext)) return
        
ShowPlayerDialog(playerid1DIALOG_STYLE_INPUT"Hi you are not registered""Welcome, you are not registered. to register please input your registration password below""Register""Leave");
        
dini_Create(file);
        
dini_IntSet(file"Password"udb_hash(inputtext));
        
dini_IntSet(file"AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
        
dini_IntSet(file"Money",PlayerInfo[playerid][pCash] = 500);
        
dini_IntSet(file"Score",PlayerInfo[playerid][pScore] = 0);
        
format(string128"[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in."nameinputtext);
        
SendClientMessage(playeridCOLOUR_YELLOWstring);
        
gPlayerLogged[playerid] = 1;
    }
    if (
dialogid == 2)
    {
        new 
name[MAX_PLAYER_NAME], file[256];
        
GetPlayerName(playeridnamesizeof(name));
        
format(filesizeof(file), SERVER_USER_FILEname);
        if(!
response) return Kick(playerid);
        if (!
strlen(inputtext)) return ShowPlayerDialog(playerid2DIALOG_STYLE_INPUT"Hi you are registered""you are already registered. to login please Inpute your password below""Login""Leave");
        new 
tmp;
        
tmp dini_Int(file"Password");
        if(
udb_hash(inputtext) != tmp) {
            
SendClientMessage(playeridCOLOUR_RED"You entered the wrong password.");
            
ShowPlayerDialog(playerid2DIALOG_STYLE_INPUT"Hi you are registered""you are already registered. to login please Inpute your password below""Login""Leave");
        }
        else
        {
            
gPlayerLogged[playerid] = 1;
            
PlayerInfo[playerid][pAdminLevel] = dini_Int(file"AdminLevel");
            
SetPlayerScore(playeridPlayerInfo[playerid][pScore]);
            
GivePlayerMoney(playeriddini_Int(file"Money")-GetPlayerMoney(playerid));
            
SendClientMessage(playerid,COLOUR_RED"[SYSTEM]: Successfully logged in!");
        }
    }
    return 
0;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
new 
cmd[256], idx;
cmd strtok(cmdtextidx);
if(
strcmp(cmd"/makeadmin"true) == 0)
{
       new 
string[128];
       new 
tmp[256];
       new 
player[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME];
       new 
giveplayerid;
       if (
IsPlayerAdmin(playerid))
       {
               
tmp strtok(cmdtextidx);
               if(!
strlen(tmp))
               {
                       
SendClientMessage(playeridCOLOUR_ORANGE"USAGE: /makeadmin [playerid] [level]");
                       
SendClientMessage(playeridCOLOUR_ORANGE"FUNCTION: Player will be an admin.");
                       return 
1;
               }
               
giveplayerid ReturnUser(tmp);
                              new 
level strval(tmp);
               if(
giveplayerid != INVALID_PLAYER_ID)
               {
                       
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                       
GetPlayerName(playeridplayersizeof(player));
                       
PlayerInfo[giveplayerid][pAdminLevel] = level;
                       
printf("Admin %s made %s a level %d admin."playergiveplayerlevel);
                       
format(stringsizeof(string), "You are now an administrator level %d thanks to %s."level,  player);
                       
SendClientMessage(giveplayerid0x00C2ECFFstring);
                       
format(stringsizeof(string), "You have given %s level %d admin.",  giveplayer,PlayerInfo[giveplayerid][pAdminLevel]);
                               
SendClientMessage(playerid0x00C2ECFFstring);
               }
               else if(
giveplayerid == INVALID_PLAYER_ID)
               {
                       
format(stringsizeof(string), "%i is not an active player."giveplayerid);
                       
SendClientMessage(playerid0xE60000FFstring);
               }
       }
       else
       {
           
SendClientMessage(playerid0xE60000FF"You are not a lead admin!");
       }
       return 
1;
}
return 
0;

errors:
PHP код:
D:\gta san andreas online\Godfucker\pawno\include\returnuser.inc(91) : error 025: function heading differs from prototype
D
:\gta san andreas online\Godfucker\pawno\include\returnuser.inc(92) : error 021symbol already defined"strtok"
D:\gta san andreas online\Godfucker\pawno\include\returnuser.inc(102) : error 047: array sizes do not match, or destination array is too small
D
:\gta san andreas online\Godfucker\My Fs\Register System Dialog\Register_Dialog.pwn(117) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\My Fs\Register System Dialog\Register_Dialog.pwn(118) : warning 217loose indentation
D
:\gta san andreas online\Godfucker\My Fs\Register System Dialog\Register_Dialog.pwn(127) : warning 217loose indentation
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
3 Errors

plz help!


Re: [HELP]admin script - omer5198 - 11.02.2011

****************************anyone??***** *****************************