SA-MP Forums Archive
/b command revamp - 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: /b command revamp (/showthread.php?tid=637134)

Pages: 1 2


/b command revamp - DrakeBell - 09.07.2017

Below is the basic code for the /b commad, I want to add something to it so that whenever an admin goes on duty via /aduty, his name within the /b chat turns dark green, and as soon as he goes off duty, the name color changes back to normal.


Code:
CMD:b(playerid, params[])
{
	if(gPlayerLogged{playerid} == 0)
	{
		SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
		return 1;
	}
	if(isnull(params)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /b [local ooc chat]");
    new string[128];
    if (PlayerInfo[playerid][pMask] == 0) {
        format(string, sizeof(string), "%s: (( %s ))", GetPlayerNameEx(playerid), params);
        ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    }
    else if (PlayerInfo[playerid][pMask] == 1) {
        format(string, sizeof(string), "Stranger: (( %s ))",  params);
        ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        
		}

      foreach(Player, i)
	{
	    if(PlayerInfo[i][pAdmin] > 1 && BigEar[i] == 2)
	    {
			new szAntiprivacy[128];
			format(szAntiprivacy, sizeof(szAntiprivacy), "(BE) %s: %s", GetPlayerNameEx(playerid), params);
			SendClientMessageEx(i, COLOR_FADE1, szAntiprivacy);
		}
	}
	return 1;
}



Re: /b command revamp - aoky - 09.07.2017

PHP Code:
CMD:b(playeridparams[])
{
    if(
gPlayerLogged{playerid} == 0)
    {
        
SendClientMessageEx(playeridCOLOR_GREY"You're not logged in.");
        return 
1;
    }
    if(
isnull(params)) return SendClientMessageEx(playeridCOLOR_WHITE"USAGE: /b [local ooc chat]");
    new 
string[128];
    if (
PlayerInfo[playerid][pMask] == 0) {
        
format(stringsizeof(string), "%s: (( %s ))"GetPlayerNameEx(playerid), params);
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    }
    else if(
PlayerInfo[i][pAdmin] > 1) {
        
format(stringsizeof(string), "{336633}%s: (( %s ))"GetPlayerNameEx(playerid), params);
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    }
    else if (
PlayerInfo[playerid][pMask] == 1) {
        
format(stringsizeof(string), "Stranger: (( %s ))",  params);
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        }
      foreach(
Playeri)
    {
        if(
PlayerInfo[i][pAdmin] > && BigEar[i] == 2)
        {
            new 
szAntiprivacy[128];
            
format(szAntiprivacysizeof(szAntiprivacy), "(BE) %s: %s"GetPlayerNameEx(playerid), params);
            
SendClientMessageEx(iCOLOR_FADE1szAntiprivacy);
        }
    }
    return 
1;

Try that.


Re: /b command revamp - DrakeBell - 09.07.2017

Quote:
Originally Posted by aoky
View Post
PHP Code:
CMD:b(playeridparams[])
{
    if(
gPlayerLogged{playerid} == 0)
    {
        
SendClientMessageEx(playeridCOLOR_GREY"You're not logged in.");
        return 
1;
    }
    if(
isnull(params)) return SendClientMessageEx(playeridCOLOR_WHITE"USAGE: /b [local ooc chat]");
    new 
string[128];
    if (
PlayerInfo[playerid][pMask] == 0) {
        
format(stringsizeof(string), "%s: (( %s ))"GetPlayerNameEx(playerid), params);
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    }
    else if(
PlayerInfo[i][pAdmin] > 1) {
        
format(stringsizeof(string), "{336633}%s: (( %s ))"GetPlayerNameEx(playerid), params);
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    }
    else if (
PlayerInfo[playerid][pMask] == 1) {
        
format(stringsizeof(string), "Stranger: (( %s ))",  params);
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        }
      foreach(
Playeri)
    {
        if(
PlayerInfo[i][pAdmin] > && BigEar[i] == 2)
        {
            new 
szAntiprivacy[128];
            
format(szAntiprivacysizeof(szAntiprivacy), "(BE) %s: %s"GetPlayerNameEx(playerid), params);
            
SendClientMessageEx(iCOLOR_FADE1szAntiprivacy);
        }
    }
    return 
1;

Try that.
Alight I'll try this and let you know the outcome.


Re: /b command revamp - DrakeBell - 09.07.2017

Go this as the only error after the compile was made

Code:
error 017: undefined symbol "i"



Re: /b command revamp - Kane - 09.07.2017

foreach(Player, i) to foreach(new i : Player) . I recommend making their name colored if they're on admin duty rather then in general, just a thought.


Re: /b command revamp - aoky - 09.07.2017

PHP Code:

CMD
:b(playeridparams[]) 

    if(
gPlayerLogged{playerid} == 0
    { 
        
SendClientMessageEx(playeridCOLOR_GREY"You're not logged in."); 
        return 
1
    } 
    if(
isnull(params)) return SendClientMessageEx(playeridCOLOR_WHITE"USAGE: /b [local ooc chat]"); 
    new 
string[128]; 
    if (
PlayerInfo[playerid][pMask] == && PlayerInfo[playerid][pAdmin] < 1) { 
        
format(stringsizeof(string), "%s: (( %s ))"GetPlayerNameEx(playerid), params); 
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5); 
    } 
    else if(
PlayerInfo[playerid][pAdmin] > 1) { 
        
format(stringsizeof(string), "{336633}%s: (( %s ))"GetPlayerNameEx(playerid), params); 
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5); 
    } 
    else if (
PlayerInfo[playerid][pMask] == 1) { 
        
format(stringsizeof(string), "Stranger: (( %s ))",  params); 
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5); 
        } 
      foreach(
Playeri
    { 
        if(
PlayerInfo[i][pAdmin] > && BigEar[i] == 2
        { 
            new 
szAntiprivacy[128]; 
            
format(szAntiprivacysizeof(szAntiprivacy), "(BE) %s: %s"GetPlayerNameEx(playerid), params); 
            
SendClientMessageEx(iCOLOR_FADE1szAntiprivacy); 
        } 
    } 
    return 
1




Re: /b command revamp - DrakeBell - 09.07.2017

It worked thankyou!


Re: /b command revamp - DrakeBell - 09.07.2017

Actually no it does not work. Doesn't change the chat color when on admin or off admin duty.


Re: /b command revamp - DrakeBell - 09.07.2017

Does not work, doesn't change the color of the name either when on admin duty or off admin duty


Re: /b command revamp - Kane - 09.07.2017

Change if(PlayerInfo[playerid][pAdminDuty]) to your scripts variable for admin duty.

I removed if(gPlayerLogged{playerid} == 0) because it's just a waste of space.

You could use public OnPlayerCommandReceived(playerid, cmdtext[]) and prevent commands if you aren't logged in.

PHP Code:
CMD:b(playeridparams[])
{
    if(
isnull(params))
        return 
SendClientMessage(playeridCOLOR_WHITE"USAGE: /b [text]"); 
     new 
           
string[128]; 
    if(
PlayerInfo[playerid][pAdminDuty])
    {
          
format(stringsizeof(string), "{336633}%s: (( %s ))"GetPlayerNameEx(playerid), params);
          
ProxDetector(20.0playeridstring,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE);
    }
    else
    {
          
format(stringsizeof(string), "%s: (( %s ))"GetPlayerNameEx(playerid), params);
          
ProxDetector(20.0playeridstring,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE,COLOR_WHITE);
    }
    foreach(new 
Player)
    {
         if(
PlayerInfo[i][pAdmin] >= && BigEar[i] == 2)
         {
              
format(stringsizeof(string), "(BE) %s: %s"GetPlayerNameEx(playerid), params);
              
SendClientMessage(iCOLOR_FADE1string);
         }
     }
   return 
true




Re: /b command revamp - aoky - 09.07.2017

PHP Code:
CMD:b(playeridparams[])  
{  
    if(
gPlayerLogged{playerid} == 0)  
    {  
        
SendClientMessageEx(playeridCOLOR_GREY"You're not logged in.");  
        return 
1;  
    }  
    if(
isnull(params)) return SendClientMessageEx(playeridCOLOR_WHITE"USAGE: /b [local ooc chat]");  
    new 
string[128];  
    if (
PlayerInfo[playerid][pMask] == && PlayerInfo[playerid][pAdmin] < 1) {  
        
format(stringsizeof(string), "%s: (( %s ))"GetPlayerNameEx(playerid), params);  
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);  
    }  
    else if(
PlayerInfo[playerid][pAdmin] > 1) {  
        
format(stringsizeof(string), "{336633}%s:{dadada} (( %s ))"GetPlayerNameEx(playerid), params);  
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);  
    }  
    else if (
PlayerInfo[playerid][pMask] == 1) {  
        
format(stringsizeof(string), "Stranger: (( %s ))",  params);  
        
ProxDetector(20.0playeridstring,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);  
        }  
      foreach(
Playeri)  
    {  
        if(
PlayerInfo[i][pAdmin] > && BigEar[i] == 2)  
        {  
            new 
szAntiprivacy[128];  
            
format(szAntiprivacysizeof(szAntiprivacy), "(BE) %s: %s"GetPlayerNameEx(playerid), params);  
            
SendClientMessageEx(iCOLOR_FADE1szAntiprivacy);  
        }  
    }  
    return 
1;  




Re: /b command revamp - DrakeBell - 09.07.2017

When I used your code it gave me this:

Code:
error 031: Undefined symbol pAdminDuty
Then I defined pAdminDuty and I got this error:

Code:
error 029: invalid expression, assumed zero
This is the line the error came on:

Code:
if(PlayerInfo[playerid][pAdminDuty])



Re: /b command revamp - Kane - 09.07.2017

Yes, rename it to the variable your script uses. If you don't have one for admin duty then just set it to pAdmin or whatever.


Re: /b command revamp - DrakeBell - 09.07.2017

Quote:
Originally Posted by Arthur Kane
View Post
Yes, rename it to the variable your script uses. If you don't have one for admin duty then just set it to pAdmin or whatever.
I dont want to rename the variables, can you help me fix the existing code please with the [pAdmin]


Re: /b command revamp - Kane - 09.07.2017

Just change if(PlayerInfo[playerid][pAdminDuty]) to [pAdmin].


Re: /b command revamp - DrakeBell - 11.07.2017

It worked but the green name for the admin stays at all times. I want to make it like whenever an administrator goes on duty, the color changes to green over /b and as soon as the administrator goes off duty the color changes back to normal.


Re: /b command revamp - Kane - 11.07.2017

What's the variable for an admin going on duty?


Re: /b command revamp - Sew_Sumi - 11.07.2017

These sort of copy-paste "try this" responses doesn't teach jack shit to the scripter.

The way that you're checking for BigEar, will show that message double, each time someone says something nearby them.


Re: /b command revamp - aoky - 11.07.2017

Send me the command for going on admin duty


Re: /b command revamp - Sew_Sumi - 11.07.2017

Quote:
Originally Posted by aoky
View Post
Send me the command for going on admin duty
Can you please take notice that your copy-paste rep hunting, isn't teaching anyone ANYTHING.

All you need is the actual AdminDuty enum, nothing more.