arrays, & params (names)
#1

Hello,

How do i make arrays names??

For example:

/setadminname <playerid> <name>

thanks in advance!
Reply
#2

You mean with sscanf?
Код:
if(sscanf(params, "us[MAX_PLAYER_NAME]", id, name)) return SendClientMessage(playerid, LIGHTBLUE, "Usage: /setadminname [ID] [Name]");
Reply
#3

pawn Код:
CMD:setadminname(playerid, params[])
{
    new iTargetID, iTargetName[MAX_PLAYER_NAME], szName[MAX_PLAYER_NAME], szString[128];
    if(sscanf(params, "is", iTargetID, szName)) SendClientMessage(playerid, COL_GREY, "USAGE: /setadminname [ID] [NAME]");
   
   
    if(!IsPlayerConnected(iTargetID)) {
        new string[128];
        format(string, sizeof(string), "WARN: Player ID: %i isn't connected!", iTargetID);
        SendClientMessage(playerid, COL_GREY, string);
    }
    GetPlayerName(iTargetID, iTargetName, sizeof(iTargetName));
   
    if(PlayerInfo[playerid][pAdmin] < 99998) return SendClientMessage(playerid, COL_GREY, "ERR: You cannot use this command!"):
    if(PlayerInfo[iTargetID][pAdmin] < 1) return SendClientMessage(playerid, COL_GREY, "ERR: %s isn't an admin!", iTargetName);
    if(PlayerInfo[iTargetID][pAdminDuty] > 0) return SendClientMessage(playerid, COL_GREY, "ERR: %s's name cannot be set because they're currently on-duty!");
    if(strlen(szName) < 3 || > 32) return SendClientMessage(playerid, COL_GREY, "ERR: Input must be more than 3 and less than 32!");
   
    format(szString, sizeof(szString), "SRV: Administrator %s has set your administrator name to ""%s.""", GetPlayerNameEx(playerid), szName);
    SendClientMessage(iTargetID, COLOR_WHITE, str);
   
    format(szString, sizeof(szString), "SRV: %s has set %s's administrator name to '%s'", GetPlayerNameEx(playerid), iTargetName, szName);
    ABroadCast(COLOR_LIGHTRED, szString, 1);
    return 1;
}
http://forum.sa-mp.com/showthread.ph...58#post2985058
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
Ari: Your code is quite wrong. For one thing, there is no length on the string specifier, and you should use "u" for players, not "i".
Can't we use "d" for players?
Reply
#5

Hanuman, 'd' is the same as 'i' so...
Reply
#6

"d" is just another integer specifier. Whereas, using "u" for users allows for both ID and part of names / full usernames.
Reply
#7

Oh, thanx both of u for making it clear
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)