command problem - 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: command problem (
/showthread.php?tid=623294)
command problem -
GabiXx - 30.11.2016
I use this:
PHP код:
CMD:setadmin(playerid, params[])
{
new pID, value;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}EROARE: {FFFFFF}Nu ai acces la aceasta comanda.");
else if(sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, COL_GOLD, "Foloseste: /setadmin [id] [adminlevel]");
else if(value < 0 || value > 7) return SendClientMessage(playerid, COL_GOLD, "Nivele valabile: 0-7.");
else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COL_TOM, "Jucatorul nu este conectat.");
else
{
new string[128], string1[128], target[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(pID, target, sizeof(target));
format(string, sizeof(string), "I-ai setat lui %s admin level %i.", target, value);
SendClientMessage(playerid, COL_GYELLOW, string);
format(string, sizeof(string), "Nivelul tau de admin a fost setat la %i de %s.", value, pName);
SendClientMessage(pID, COL_GYELLOW, string1);
PlayerInfo[pID][pAdmin] = value;
}
return 1;
}
When i set a player adminlevel, he don't get the message from string. I get the message, he get a blank space in chat.
Re: command problem - adri[4]Life - 30.11.2016
try with this
Код:
SendClientMessage(playerid, COLOR, "Your Text Here");
Re: command problem -
Logic_ - 30.11.2016
PHP код:
SendClientMessage(pID, COL_GYELLOW, string1);
this should be
PHP код:
SendClientMessage(pID, COL_GYELLOW, string);
How the new code will look like:
PHP код:
CMD:setadmin(playerid, params[])
{
new pID, value;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{FF0000}EROARE: {FFFFFF}Nu ai acces la aceasta comanda.");
else if(sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, COL_GOLD, "Foloseste: /setadmin [id] [adminlevel]");
else if(value < 0 || value > 7) return SendClientMessage(playerid, COL_GOLD, "Nivele valabile: 0-7.");
else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COL_TOM, "Jucatorul nu este conectat.");
else
{
new string[100], target[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(pID, target, sizeof(target));
format(string, sizeof(string), "I-ai setat lui %s admin level %i.", target, value);
SendClientMessage(playerid, COL_GYELLOW, string);
format(string, sizeof(string), "Nivelul tau de admin a fost setat la %i de %s.", value, pName);
SendClientMessage(pID, COL_GYELLOW, string);
PlayerInfo[pID][pAdmin] = value;
}
return 1;
}
How we fixed and what you need to learn:
- You can format a string as many times as you like, you can use one variable, format the message in it, send it to the player, format the message again, send it to another player.
- You were using two variables for string.
- Don't use un-needed holder for variables, for example "new string[128]" when your string is a lot less, for example "new string[90]"
Re: command problem -
GabiXx - 30.11.2016
Thanks