SA-MP Forums Archive
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(playeridparams[])
{
    new 
pIDvalue;
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1"{FF0000}EROARE: {FFFFFF}Nu ai acces la aceasta comanda.");
    else if(
sscanf(params"ui"pIDvalue)) return SendClientMessage(playeridCOL_GOLD"Foloseste: /setadmin [id] [adminlevel]");
    else if(
value || value 7) return SendClientMessage(playeridCOL_GOLD"Nivele valabile: 0-7.");
    else if(
pID == INVALID_PLAYER_ID) return SendClientMessage(playeridCOL_TOM"Jucatorul nu este conectat.");
    else
    {
        new 
string[128], string1[128], target[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME];
        
GetPlayerName(playeridpNamesizeof(pName));
        
GetPlayerName(pIDtargetsizeof(target));
        
format(stringsizeof(string), "I-ai setat lui %s admin level %i."targetvalue);
        
SendClientMessage(playeridCOL_GYELLOWstring);
        
format(stringsizeof(string), "Nivelul tau de admin a fost setat la %i de %s."valuepName);
        
SendClientMessage(pIDCOL_GYELLOWstring1);
        
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(pIDCOL_GYELLOWstring1); 
this should be

PHP код:
SendClientMessage(pIDCOL_GYELLOWstring); 
How the new code will look like:
PHP код:
CMD:setadmin(playeridparams[]) 

    new 
pIDvalue
    if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1"{FF0000}EROARE: {FFFFFF}Nu ai acces la aceasta comanda."); 
    else if(
sscanf(params"ui"pIDvalue)) return SendClientMessage(playeridCOL_GOLD"Foloseste: /setadmin [id] [adminlevel]"); 
    else if(
value || value 7) return SendClientMessage(playeridCOL_GOLD"Nivele valabile: 0-7."); 
    else if(
pID == INVALID_PLAYER_ID) return SendClientMessage(playeridCOL_TOM"Jucatorul nu este conectat."); 
    else 
    {
        new 
string[100], target[MAX_PLAYER_NAME], pName[MAX_PLAYER_NAME]; 
        
GetPlayerName(playeridpNamesizeof(pName));
        
GetPlayerName(pIDtargetsizeof(target));
        
format(stringsizeof(string), "I-ai setat lui %s admin level %i."targetvalue);
        
SendClientMessage(playeridCOL_GYELLOWstring);
        
format(stringsizeof(string), "Nivelul tau de admin a fost setat la %i de %s."valuepName);
        
SendClientMessage(pIDCOL_GYELLOWstring);
        
PlayerInfo[pID][pAdmin] = value;
    } 
    return 
1

How we fixed and what you need to learn:
  1. 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.
  2. You were using two variables for string.
  3. 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