CMD:aname?
#7

Quote:
Originally Posted by runcis
Посмотреть сообщение
PHP код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <dini>
#pragma tabsize 0
#define COLOR_WHITE (0xFFFFFFAA)
#define COLOR_GREY     (0xAFAFAFAA)
enum pInfo {
    
pAdmin
};
new 
PlayerInfo[MAX_PLAYERS][pInfo];
new 
boolaDuty[MAX_PLAYERS];
PlayerName(playerid)
{
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    return 
name;
}
ReturnIP(playerid)
{
    static
        
ip[16];
    
GetPlayerIp(playeridipsizeof(ip));
    return 
ip;
}
CMD:aduty(playeridparams[])
{
    if (
PlayerInfo[playerid][pAdmin] < 1)
        return 
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
        
    if (!
aDuty[playerid]) {
        
SendClientMessage(playerid, -1"You are now in adminduty!");
        
aDuty[playerid] = true;
    } else {
        
SendClientMessage(playerid, -1"You are no longer adminduty!");
        
aDuty[playerid] = false;
    }
    return 
1;
}
CMD:aname(playeridparams[])
{
    new 
string[128], file[32], text[MAX_PLAYER_NAME];
    if (
PlayerInfo[playerid][pAdmin] < 1)
        return 
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
        
    if (
sscanf(params"s[24]"text))
        return 
SendClientMessage(playeridCOLOR_WHITE"USAGE: /aname [name]");
        
    if (
aDuty[playerid])
        return 
SendClientMessage(playeridCOLOR_GREY"You must be off duty to change your admin name.");
        
    
// Start of detecting space in name
    
new endtemp[32], temp2[32];
    
end strfind(text" ",true);
    if(
end != -1)
    {
        
strmid(temptext0end);
        
format(tempsizeof(temp), "%s_"temp);
        
strdel(text0end);
        
strmid(temp2text1strlen(text));
        
format(text24"");
        
strcat(texttempsizeof(temp));
        
strcat(texttemp2sizeof(temp2));
    }
    
// End of detecting space in name
    
format(filesizeof(file), "users/%s.ini"text);
    if(
dini_Exists(file))
    {
        
format(filesizeof(file), "users/%s.ini"PlayerName(playerid));
        if(
strlen(dini_Get(file"AdminName")) && strcmp(dini_Get(file"AdminName"), text))
        {
             
SendClientMessage(playeridCOLOR_GREY"Name is already in use.");
            return 
1;
        }
    }
    
format(stringsizeof(string), " You have changed your admin name to: {FF6347}%s"text);
    
SendClientMessage(playeridCOLOR_WHITEstring);
    
format(filesizeof(file), "users/%s.ini"PlayerName(playerid));
    
format(filesizeof(file), "users/%s.ini"dini_Get(file"AdminName"));
    if(
dini_Exists(file)) dini_Remove(file);
    
format(filesizeof(file), "users/%s.ini"PlayerName(playerid));
    
dini_Set(file"AdminName"text);
    
format(filesizeof(file), "users/%s.ini",dini_Get(file"AdminName"));
    
dini_Create(file);
    
dini_Set(file"OldName"PlayerName(playerid));
    
dini_IntSet(file"Admin"PlayerInfo[playerid][pAdmin]);
    
dini_IntSet(file"AdminAccount"1);
    
dini_IntSet(file"Age"25);
    
dini_IntSet(file"Gender"1);
    
dini_IntSet(file"Tutorial"1);
    
dini_Set(file"IP"ReturnIP(playerid));
    return 
1;

Works with no errors, but is it able to use my own aduty and just the CMD:aname there? I already have my own /aduty on my script, im adding aname as a filterscript
Reply


Messages In This Thread
CMD:aname? - by DGRP - 23.08.2015, 12:04
Re: CMD:aname? - by thaKing - 23.08.2015, 12:07
Re : Re: CMD:aname? - by DGRP - 23.08.2015, 12:15
Re: CMD:aname? - by Fancy - 23.08.2015, 12:27
Re: CMD:aname? - by thaKing - 23.08.2015, 12:27
Re : Re: CMD:aname? - by DGRP - 23.08.2015, 12:33
Re : Re: CMD:aname? - by DGRP - 23.08.2015, 12:37
Re: CMD:aname? - by thaKing - 23.08.2015, 12:38
Re : Re: CMD:aname? - by DGRP - 23.08.2015, 12:50
Re: CMD:aname? - by Infinity - 25.08.2015, 17:27

Forum Jump:


Users browsing this thread: 1 Guest(s)