/setname error ..
#1

I'm trying to create a /setname command, but each time i get errors..

\test2.pwn(2256) : error 035: argument type mismatch (argument 3)

Here's the code:

pawn Код:
CMD:setname(playerid, params[]) {
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!");
    new string[84], newname[20], id;
    new originalname[MAX_PLAYER_NAME];
    GetPlayerName(id, originalname, sizeof(originalname));
    new plrIP[16];
    if(sscanf(params, "uc[20]", id, newname)) return SendClientMessage(playerid, COLOR_RED, "[USAGE] - /setname [ID] [NewName]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "[NOTE] - Player not found!");

    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(id));
    INI_WriteInt(File,"Admin",PlayerInfo[id][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[id][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[id][pDeaths]);
    INI_WriteInt(File,"Score",GetPlayerScore(id));
    INI_WriteInt(File,"Password",PlayerInfo[id][pPass]);
    INI_WriteInt(File,"Muted",PlayerInfo[id][pMuted]);
    INI_WriteInt(File,"VIP",PlayerInfo[id][pVIP]);
    //INI_WriteInt(File,"Reward",PlayerInfo[playerid][pReward]);
    INI_WriteInt(File,"IP",GetPlayerIp(id, plrIP, sizeof(plrIP)));
    INI_WriteInt(File,"TimesWarned",PlayerInfo[id][pTimesWarned]);
    INI_WriteInt(File,"TimeKicked",PlayerInfo[id][pTimesKicked]);
    INI_WriteInt(File,"LoggedIn",PlayerInfo[id][pLoggedIn]);
    INI_WriteInt(File,"Banned",PlayerInfo[id][pBanned]);
    INI_WriteInt(File,"OriginalName",originalname); //error line
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    new receiver[MAX_PLAYER_NAME];
    GetPlayerName(id, receiver, sizeof(receiver));
   
    format(string, sizeof(string), "[ADMIN] - %s[%d] has used SETNAME on %s[%d]", pName, playerid, receiver, id);
    SendMessageToAdmins(string);
   
    format(string, sizeof(string), "* Your name has been changed to %s by %s[%d]", newname, pName, playerid);
    SendClientMessage(id, COLOR_YELLOW, string);
   
    format(string, sizeof(string), "%s", newname);
    SetPlayerName(id, string);
    return 1;
}
Reply
#2

Which line is showing the error?
Reply
#3

Quote:
Originally Posted by ViciousRoleplay123
Посмотреть сообщение
Which line is showing the error?
pawn Код:
INI_WriteInt(File,"OriginalName",originalname); //error line
Reply
#4

try
pawn Код:
INI_WriteInt(File,"OriginalName",PlayerInfo[id][pOriginalName]);
Reply
#5

Quote:
Originally Posted by rakshith122
Посмотреть сообщение
try
INI_WriteInt(File,"Reward",PlayerInfo[id][pReward]);
I don't have an enum for the "OriginalName", since i think i can use "new ...."

Also, if i try to use an enum ->

Код:
 \test2.pwn(2237) : error 006: must be assigned to an array
Line 2237:

pawn Код:
PlayerInfo[id][pOriginalName] = originalname;

EDIT

pawn Код:
PlayerInfo[id][pOriginalName] = GetPlayerName(id, originalname, sizeof(originalname));
Did compile, gonna test it..
Reply
#6

...
...Deleted
Reply
#7

pawn Код:
INI_WriteString(File,"OriginalName",originalname);
It writes a string, not an integer.
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
INI_WriteString(File,"OriginalName",originalname);
It writes a string, not an integer.
Well, i "fixed" it now, but now i have this issue:



Code again(If needed)

pawn Код:
CMD:setname(playerid, params[]) {
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!");
    new string[84], newname[20], id;
    new originalname[MAX_PLAYER_NAME];
    PlayerInfo[id][pOriginalName] = GetPlayerName(id, originalname, sizeof(originalname)); //Should i edit something here?
    new plrIP[16];
    if(sscanf(params, "us[20]", id, newname)) return SendClientMessage(playerid, COLOR_RED, "[USAGE] - /setname [ID] [NewName]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "[NOTE] - Player not found!");

    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(id));
    INI_WriteInt(File,"Admin",PlayerInfo[id][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[id][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[id][pDeaths]);
    INI_WriteInt(File,"Score",GetPlayerScore(id));
    INI_WriteInt(File,"Password",PlayerInfo[id][pPass]);
    INI_WriteInt(File,"Muted",PlayerInfo[id][pMuted]);
    INI_WriteInt(File,"VIP",PlayerInfo[id][pVIP]);
    //INI_WriteInt(File,"Reward",PlayerInfo[playerid][pReward]);
    INI_WriteInt(File,"IP",GetPlayerIp(id, plrIP, sizeof(plrIP)));
    INI_WriteInt(File,"TimesWarned",PlayerInfo[id][pTimesWarned]);
    INI_WriteInt(File,"TimeKicked",PlayerInfo[id][pTimesKicked]);
    INI_WriteInt(File,"LoggedIn",PlayerInfo[id][pLoggedIn]);
    INI_WriteInt(File,"Banned",PlayerInfo[id][pBanned]);
    INI_WriteInt(File,"OriginalName",PlayerInfo[id][pOriginalName]);
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    new receiver[MAX_PLAYER_NAME];
    GetPlayerName(id, receiver, sizeof(receiver));
   
    format(string, sizeof(string), "[ADMIN] - %s[%d] has used SETNAME on %s[%d]", pName, playerid, receiver, id);
    SendMessageToAdmins(string);
   
    format(string, sizeof(string), "* Your name has been changed to %s by %s[%d]", newname, pName, playerid);
    SendClientMessage(id, COLOR_YELLOW, string);
   
    format(string, sizeof(string), "%s", newname);
    SetPlayerName(id, string);
    return 1;
}

The
pawn Код:
PlayerInfo[id][pOriginalName] = GetPlayerName(id, originalname, sizeof(originalname));
Should "store" the players Original name..
Reply
#9

GetPlayerName returns the lenght of the player's name. This is not how we copy a string to another string.

pawn Код:
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
pawn Код:
strcpy(PlayerInfo[id][pOriginalName], originalname, MAX_PLAYER_NAME);
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
GetPlayerName returns the lenght of the player's name. This is not how we copy a string to another string.

pawn Код:
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
pawn Код:
strcpy(PlayerInfo[id][pOriginalName], originalname, MAX_PLAYER_NAME);
Eh, i got lots of errors with it.. ( If you wanted me to use it, dunno.. .__. )

One was at "#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)"
-- test2.pwn(117) : warning 201: redefinition of constant/macro (symbol "strcpy(%0,%1,%2)") --

And the others were at "strcpy(PlayerInfo[id][pOriginalName], originalname, MAX_PLAYER_NAME);"
-- test2.pwn(2241) : error 001: expected token: ")", but found "["
-- test2.pwn(2241) : warning 215: expression has no effect
-- test2.pwn(2241) : error 001: expected token: ";", but found "]"
-- test2.pwn(2241) : error 029: invalid expression, assumed zero
-- test2.pwn(2241) : fatal error 107: too many error messages on on
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)