SA-MP Forums Archive
CMD:aname? - 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)
+--- Thread: CMD:aname? (/showthread.php?tid=586596)



CMD:aname? - DGRP - 23.08.2015

I'm trying to make /aname command, but keeps on getting errors, These are my codes:

Код:
C:\Users\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(23) : error 017: undefined symbol "aDuty"
C:\Users\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(23) : warning 215: expression has no effect
C:\Users\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(23) : error 001: expected token: ";", but found "]"
C:\Users\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(23) : error 029: invalid expression, assumed zero
C:\Users\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(23) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
This is my code

Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <dini>
#pragma tabsize 0


#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_GREY 0xAFAFAFAA

new IsPlayerLoggedIn[MAX_PLAYERS]; 

enum pInfo {
pAdmin
};
new PlayerInfo[MAX_PLAYERS][pInfo];

CMD:aname(playerid, params[])
{
	new string[128], file[32], text[MAX_PLAYER_NAME];
	if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
	if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /aname [name]");
	if(aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You must be off duty to change your admin name.");
	// Start of detecting space in name
	new end, temp[32], temp2[32];
	end = strfind(text, " ",true);
	if(end != -1)
	{
	    strmid(temp, text, 0, end);
	    format(temp, sizeof(temp), "%s_", temp);
	    strdel(text, 0, end);
		strmid(temp2, text, 1, strlen(text));
	    format(text, 24, "");
	    strcat(text, temp, sizeof(temp));
	    strcat(text, temp2, sizeof(temp2));
	}
	// End of detecting space in name
	format(file, sizeof(file), "users/%s.ini", text);
	if(dini_Exists(file))
	{
	    format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
	    if(strlen(dini_Get(file, "AdminName")) && strcmp(dini_Get(file, "AdminName"), text))
	    {
	     	SendClientMessage(playerid, COLOR_GREY, "Name is already in use.");
	        return 1;
	    }
	}
	format(string, sizeof(string), " You have changed your admin name to: {FF6347}%s", text);
	SendClientMessage(playerid, COLOR_WHITE, string);
	format(string, sizeof(string), "%s has changed their admin name to %s.", RPN(playerid), text);
	Log("logs/aname.log", string);
	format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
	format(file, sizeof(file), "users/%s.ini", dini_Get(file, "AdminName"));
	if(dini_Exists(file)) dini_Remove(file);
	format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
	dini_Set(file, "AdminName", text);
	format(file, sizeof(file), "users/%s.ini",dini_Get(file, "AdminName"));
	dini_Create(file);
	dini_Set(file, "OldName", RPNU(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", PlayerInfo[playerid][pIP]);
	return 1;
}



Re: CMD:aname? - thaKing - 23.08.2015

Under new IsPlayerLoggedIn[MAX_PLAYERS]; add

PHP код:
new    boolaDuty[MAX_PLAYERS]; 



Re : Re: CMD:aname? - DGRP - 23.08.2015

Quote:
Originally Posted by runcis
Посмотреть сообщение
Under new IsPlayerLoggedIn[MAX_PLAYERS]; add

PHP код:
new    boolaDuty[MAX_PLAYERS]; 
Now I get this error

Код:
C:\Users\Rizal\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(42) : error 017: undefined symbol "RPNU"
C:\Users\Rizal\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(51) : error 017: undefined symbol "RPN"
C:\Users\Rizal\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(52) : error 017: undefined symbol "Log"
C:\Users\Rizal\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(53) : error 017: undefined symbol "RPNU"
C:\Users\Rizal\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(56) : error 017: undefined symbol "RPNU"
C:\Users\Rizal\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(60) : error 017: undefined symbol "RPNU"
C:\Users\Rizal\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(66) : error 017: undefined symbol "pIP"
C:\Users\Rizal\Desktop\PR RP SCRIPT NEW\filterscripts\aname.pwn(69) : warning 203: symbol is never used: "IsPlayerLoggedIn"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase



Re: CMD:aname? - Fancy - 23.08.2015

Try this:

Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <dini>
#pragma tabsize 0


#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_GREY 0xAFAFAFAA

new IsPlayerLoggedIn[MAX_PLAYERS]; 

enum pInfo {
pAdmin
};
new PlayerInfo[MAX_PLAYERS][pInfo];
new aDuty[MAX_PLAYERS];

CMD:aname(playerid, params[])
{
	new string[128], file[32], text[MAX_PLAYER_NAME];
	if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
	if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /aname [name]");
	if(aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You must be off duty to change your admin name.");
	// Start of detecting space in name
	new end, temp[32], temp2[32];
	end = strfind(text, " ",true);
	if(end != -1)
	{
	    strmid(temp, text, 0, end);
	    format(temp, sizeof(temp), "%s_", temp);
	    strdel(text, 0, end);
		strmid(temp2, text, 1, strlen(text));
	    format(text, 24, "");
	    strcat(text, temp, sizeof(temp));
	    strcat(text, temp2, sizeof(temp2));
	}
	// End of detecting space in name
	format(file, sizeof(file), "users/%s.ini", text);
	if(dini_Exists(file))
	{
	    format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
	    if(strlen(dini_Get(file, "AdminName")) && strcmp(dini_Get(file, "AdminName"), text))
	    {
	     	SendClientMessage(playerid, COLOR_GREY, "Name is already in use.");
	        return 1;
	    }
	}
	format(string, sizeof(string), " You have changed your admin name to: {FF6347}%s", text);
	SendClientMessage(playerid, COLOR_WHITE, string);
	format(string, sizeof(string), "%s has changed their admin name to %s.", RPN(playerid), text);
	Log("logs/aname.log", string);
	format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
	format(file, sizeof(file), "users/%s.ini", dini_Get(file, "AdminName"));
	if(dini_Exists(file)) dini_Remove(file);
	format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
	dini_Set(file, "AdminName", text);
	format(file, sizeof(file), "users/%s.ini",dini_Get(file, "AdminName"));
	dini_Create(file);
	dini_Set(file, "OldName", RPNU(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", PlayerInfo[playerid][pIP]);
	return 1;
}



Re: CMD:aname? - thaKing - 23.08.2015

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;




Re : Re: CMD:aname? - DGRP - 23.08.2015

Quote:
Originally Posted by Fancy
Посмотреть сообщение
Try this:

Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <dini>
#pragma tabsize 0


#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_GREY 0xAFAFAFAA

new IsPlayerLoggedIn[MAX_PLAYERS]; 

enum pInfo {
pAdmin
};
new PlayerInfo[MAX_PLAYERS][pInfo];
new aDuty[MAX_PLAYERS];

CMD:aname(playerid, params[])
{
	new string[128], file[32], text[MAX_PLAYER_NAME];
	if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
	if(sscanf(params, "s[24]", text)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /aname [name]");
	if(aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You must be off duty to change your admin name.");
	// Start of detecting space in name
	new end, temp[32], temp2[32];
	end = strfind(text, " ",true);
	if(end != -1)
	{
	    strmid(temp, text, 0, end);
	    format(temp, sizeof(temp), "%s_", temp);
	    strdel(text, 0, end);
		strmid(temp2, text, 1, strlen(text));
	    format(text, 24, "");
	    strcat(text, temp, sizeof(temp));
	    strcat(text, temp2, sizeof(temp2));
	}
	// End of detecting space in name
	format(file, sizeof(file), "users/%s.ini", text);
	if(dini_Exists(file))
	{
	    format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
	    if(strlen(dini_Get(file, "AdminName")) && strcmp(dini_Get(file, "AdminName"), text))
	    {
	     	SendClientMessage(playerid, COLOR_GREY, "Name is already in use.");
	        return 1;
	    }
	}
	format(string, sizeof(string), " You have changed your admin name to: {FF6347}%s", text);
	SendClientMessage(playerid, COLOR_WHITE, string);
	format(string, sizeof(string), "%s has changed their admin name to %s.", RPN(playerid), text);
	Log("logs/aname.log", string);
	format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
	format(file, sizeof(file), "users/%s.ini", dini_Get(file, "AdminName"));
	if(dini_Exists(file)) dini_Remove(file);
	format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
	dini_Set(file, "AdminName", text);
	format(file, sizeof(file), "users/%s.ini",dini_Get(file, "AdminName"));
	dini_Create(file);
	dini_Set(file, "OldName", RPNU(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", PlayerInfo[playerid][pIP]);
	return 1;
}
Still dont work.


Re : Re: CMD:aname? - DGRP - 23.08.2015

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


Re: CMD:aname? - thaKing - 23.08.2015

yes, it is, just delete cmd:aduty

I mean whole command, not only cmd:aduty(playerid, params[])


Re : Re: CMD:aname? - DGRP - 23.08.2015

Quote:
Originally Posted by runcis
Посмотреть сообщение
yes, it is, just delete cmd:aduty

I mean whole command, not only cmd:aduty(playerid, params[])
Thank you, Repped!


Re: CMD:aname? - Infinity - 25.08.2015

Also, please remove that horrible pragma...