How to Send a message to Admins,
#1

Hey, I need help sending a message to an admin only, I need to know what to do so I can do so, Thanks ahead of time. Whoever helps will get +1 rep.
Reply
#2

https://sampwiki.blast.hk/wiki/Loop

Check Example with loop. Its exacly what you need it for.
Reply
#3

Repped. Thanks a lot for showing me this.
Reply
#4

No problem.
Reply
#5

Another Question, I want to make it into a stock.
pawn Код:
stock sendtoadmins(playerid)
{
new string[128];
for(new i = 0; < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[playerid][pAdmin] > 1)
        format(string,sizeof(string),"%s");
        SendClientMessage(sendtoadmins,COLOR_YELLOW,string);
    }
    return 1;
}
so I can put like sendtoadmins some where in the script to send it to the admins.. Where I would put it for example

pawn Код:
CMD:agivekp(playerid,params[]){
    new string[128],id,amount;
    if(PlayerInfo[playerid][pAdminDuty] == 0) return SendClientMessage(playerid,COLOR_GRAY,"You're not on admin duty!");
    if(PlayerInfo[playerid][pAdmin] > 2) return SendClientMessage(playerid,COLOR_GRAY,"You're not authorized to use this command!");
    if(sscanf(params,"US",id,amount)) return SendClientMessage(playerid,COLOR_GRAY,"SYNTAX: /agivekp [id] [amount]");
    else if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_GRAY,"Player is not connected!");
    else
    {
    PlayerInfo[playerid][pKillPoints] = amount;
    }
    format(string,sizeof(string),"%s has just gave %s [%d] killpoints!",GetName(playerid),GetName(id),amount);
    SendClientMessageToAll(COLOR_YELLOW,string);
    return 1;
}
So the string would get sent to admins only?
Reply
#6

PHP код:
stock SendToAdmins(COLOR,message[])
{
    new 
string[128];
    for(new 
0; < MAX_PLAYERSi++)
     if(
PlayerInfo[i][pAdmin] > 1)
     {
        
SendClientMessage(i,COLOR,message);
    }
    return 
0;
}

CMD:agivekp(playerid,params[])
{
    new 
string[128],id,amount;
    if(
PlayerInfo[playerid][pAdminDuty] == 0) return SendClientMessage(playerid,COLOR_GRAY,"You're not on admin duty!");
    if(
PlayerInfo[playerid][pAdmin] > 2) return SendClientMessage(playerid,COLOR_GRAY,"You're not authorized to use this command!");
    if(
sscanf(params,"us",id,amount)) return SendClientMessage(playerid,COLOR_GRAY,"SYNTAX: /agivekp [id] [amount]");
    if(!
IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_GRAY,"Player is not connected!");
    
PlayerInfo[playerid][pKillPoints] = amount;
    
format(string,sizeof(string),"%s has just gave %s [%i] killpoints!",GetName(playerid),GetName(id),amount);
    
SendToAdmin(COLOR_YELLOW,string);
    return 
1;

Should work I fixed it for ya
Reply
#7

Any way you could comment what does what? Like the end of the SendToAdmins the "[]" and why it returns 0?
Код:
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(837) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(837) : warning 215: expression has no effect
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(837) : error 001: expected token: ")", but found ";"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(837) : error 036: empty statement
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(837) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
pawn Код:
stock SendToAdmins(COLOR,message[])
{
    new string[128];
    for(new i = 0; < MAX_PLAYERS; i++)
    if(PlayerInfo[i][pAdmin] > 1)
    {
        SendClientMessage(i,COLOR,message);
    }
    return 0;
}
Reply
#8

PHP код:
stock SendToAdmins(COLOR,message[])//here we set params for this stock, [] means string/message
{
    new 
string[128];
    for(new 
0; < MAX_PLAYERSi++)//here we created loop
     
if(PlayerInfo[i][pAdmin] > 1// we are checking are all players admins
     
{
        
SendClientMessage(i,COLOR,message);//for those which are send message from first line in COLOR from first line
    
}
    else return 
0//for everyone else return 0;

Reply
#9

Thats what i exactly told you yesterday, azzeto
Reply
#10

I know, but how you explained it, it just didnt make any sence, He explained it better (gave your rep for helping me with the aduty) and dimi, could I just put return 0; at the end of if(PlayerInfo[i][pAdmin] > 1) return 0; like that?
Reply
#11

No. What you said means if player's level is higher than one stop function. And you wanted to send message if player's level is higher than one.
Reply
#12

Just hold it like that. When the player is NOT an admin, it wont send him the message
Reply
#13

My bad, I ment < 1 but I get the four errors..
Код:
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(837) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(837) : warning 215: expression has no effect
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(837) : error 001: expected token: ")", but found ";"
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(837) : error 036: empty statement
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(837) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#14

pawn Код:
stock SendToAdmins(COLOR,message[])//here we set params for this stock, [] means string/message
{
    new string[128];
    for( new i = 0; i < MAX_PLAYERS; i++ )//here we created loop
    if( PlayerInfo[i][pAdmin] > 1 ) // we are checking are all players admins
    {
        SendClientMessage( i,COLOR,message );//for those which are send message from first line in COLOR from first line
    }
    else return 0; //for everyone else return 0;
}
That will do it, he forgot an 'i' in the loop
Reply
#15

Ok, 1 error.
Код:
C:\Documents and Settings\Customer\Desktop\GameMode\gamemodes\gangwar.pwn(838) : error 017: undefined symbol "i"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#16

And can you show at which line that is? Is it in the stock, or where you use the SendToAdmin?
Reply
#17

Код:
stock SendToAdmins(COLOR,message[])
{
	for( new i = 0; i < MAX_PLAYERS; i++ )
	if(PlayerInfo[i][pAdmin] < 1) return 0;
 	SendClientMessage(i,COLOR,message);//heres the error..
	return 1;
}
Reply
#18

LOL forgot the brackets after the loop
stock SendToAdmins(COLOR,message[])
{
for( new i = 0; i < MAX_PLAYERS; i++ )
{
if(PlayerInfo[i][pAdmin] < 1) return 0;
SendClientMessage(i,COLOR,message);
}
return 1;
}
Thanks anyways, repped +1
Reply
#19

No problem. Wasn't here so couldnt answer right away.
Reply
#20

Код:
stock SendToAdmins(COLOR,string[])//here we set params for this stock, [] means string/message
{
    new string[128];
    for(new i = 0; < MAX_PLAYERS; i++)//here we created loop
     if(PlayerInfo[i][pAdmin] > 1) // we are checking are all players admins
     {
        SendClientMessage(i,COLOR,string);//for those which are send message from first line in COLOR from first line
    }
    else return 0; //for everyone else return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)