SA-MP Forums Archive
arrays, & params (names) - 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: arrays, & params (names) (/showthread.php?tid=505802)



arrays, & params (names) - ChristianIvann09 - 10.04.2014

Hello,

How do i make arrays names??

For example:

/setadminname <playerid> <name>

thanks in advance!


Re: arrays, & params (names) - Danijel. - 10.04.2014

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



Re: arrays, & params (names) - Ari - 10.04.2014

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


Re: arrays, & params (names) - Hanuman - 10.04.2014

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?


Re: arrays, & params (names) - Stinged - 10.04.2014

Hanuman, 'd' is the same as 'i' so...


Re: arrays, & params (names) - Isolated - 10.04.2014

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


Re: arrays, & params (names) - Hanuman - 10.04.2014

Oh, thanx both of u for making it clear