if(strcmp(cmd, "/setprefix", true) == 0) { if(IsPlayerConnected(playerid)) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "Usage: /setprefix [playerid] [Prefix text]"); return 1; } new para1; new prefix; para1 = ReturnUser(tmp); tmp = strtok(cmdtext, idx); prefix = strval(tmp); if (pInfo[playerid][Adminlevel] >= 6 || IsPlayerAdmin(playerid)) { if(IsPlayerConnected(para1)) { if(para1 != INVALID_PLAYER_ID) { GetPlayerName(para1, giveplayer, sizeof(giveplayer)); format(string, sizeof(string), "PREFIX: Administrator {FFFF00}%s {00FFFF} set you PREFIX {FFFF00}%s {00FFFF}. Congratulations!", PlayerName(playerid), prefix); SendClientMessage(para1, COLOR_ORANGE, string); pInfo[para1][Prefix] = prefix; format(string, sizeof(string), "PREFIX: {FFFF00}%s {00FFFF} now have PREFIX {FFFF00}%s{00FFFF}. Congratulations!", giveplayer, prefix); SendClientMessageToAll(COLOR_ORANGE, string); } } } else { SendClientMessage(playerid, COLOR_RED, "You have no access to this command!"); } } return 1; }
CMD:setprefix(playerid, params[]) { new prefix[100], id; if (sscanf(params, "us[100]", id, prefix)) { SendClientMessage(playerid, COLOR_WHITE, "Usage: /setprefix [playerid/name] [Prefix text]"); return 1; } if (pInfo[playerid][Adminlevel] >= 6 || IsPlayerAdmin(playerid)) { if(IsPlayerConnected(id)) { GetPlayerName(id, giveplayer, sizeof(giveplayer)); format(string, sizeof(string), "PREFIX: Administrator {FFFF00}%s {00FFFF} set you PREFIX {FFFF00}%s {00FFFF}. Congratulations!", PlayerName(playerid), prefix); SendClientMessage(id, COLOR_ORANGE, string); pInfo[id][Prefix] = prefix; format(string, sizeof(string), "PREFIX: {FFFF00}%s {00FFFF} now have PREFIX {FFFF00}%s{00FFFF}. Congratulations!", giveplayer, prefix); SendClientMessageToAll(COLOR_ORANGE, string); } } else { SendClientMessage(playerid, COLOR_RED, "You have no access to this command!"); } return 1; }
Can we PLEASE update to something more advanced? Download ZCMD and sscanf:
Код:
CMD:setprefix(playerid, params[]) { new prefix[100], id; if (sscanf(params, "us[100]", id, prefix)) { SendClientMessage(playerid, COLOR_WHITE, "Usage: /setprefix [playerid/name] [Prefix text]"); return 1; } if (pInfo[playerid][Adminlevel] >= 6 || IsPlayerAdmin(playerid)) { if(IsPlayerConnected(id)) { GetPlayerName(id, giveplayer, sizeof(giveplayer)); format(string, sizeof(string), "PREFIX: Administrator {FFFF00}%s {00FFFF} set you PREFIX {FFFF00}%s {00FFFF}. Congratulations!", PlayerName(playerid), prefix); SendClientMessage(id, COLOR_ORANGE, string); pInfo[id][Prefix] = prefix; format(string, sizeof(string), "PREFIX: {FFFF00}%s {00FFFF} now have PREFIX {FFFF00}%s{00FFFF}. Congratulations!", giveplayer, prefix); SendClientMessageToAll(COLOR_ORANGE, string); } } else { SendClientMessage(playerid, COLOR_RED, "You have no access to this command!"); } return 1; } ZCMDS https://sampforum.blast.hk/showthread.php?tid=91354 sscanf https://sampforum.blast.hk/showthread.php?tid=570927 |
if(strcmp(cmd, "/setprefix", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Usage: /setprefix [playerid] [Prefix text]");
return 1;
}
new para1;
new prefix[30];
para1 = ReturnUser(tmp);
prefix = strtok(cmdtext, idx);
if (pInfo[playerid][Adminlevel] >= 6 || IsPlayerAdmin(playerid))
{
if(IsPlayerConnected(para1))
{
if(para1 != INVALID_PLAYER_ID)
{
GetPlayerName(para1, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "PREFIX: Administrator {FFFF00}%s {00FFFF} set you PREFIX {FFFF00}%s {00FFFF}. Congratulations!", PlayerName(playerid), prefix);
SendClientMessage(para1, COLOR_ORANGE, string);
pInfo[para1][Prefix] = prefix;
format(string, sizeof(string), "PREFIX: {FFFF00}%s {00FFFF} now have PREFIX {FFFF00}%s{00FFFF}. Congratulations!", giveplayer, prefix);
SendClientMessageToAll(COLOR_ORANGE, string);
}
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You have no access to this command!");
}
}
return 1;
}
Hello!
PHP код:
|
Thank you very much, man! This is the assistance that I expected.
May I ask one more thing? I want the prefix to CAN contain spaces between the words. In the moment if I type "Prefix with spaces", it will set only "Prefix" for prefix. I also want to prefix must contain at least 1 character, because in the moment I can set empty prefix. |