Jump to content

stock sendaminmessage


A simple Egg

Recommended Posts

Salut, pai poti incepe prin 

stock SendAdminMessage(level, color, const string[], va_args<>)

Apoi recomand folosirea iteratorului pentru a fi mai simplu.

Dupa care faci o verificare daca nivelul de admin al acelui admin este mai mare sau egal cu level-ul din stock.

Apoi prin SCM(playerid, color, va_return(string, va_start<3>));

Si un return la final :) Sper ca te-am ajutat, daca nu intelegi o sa iti fac eu de la 0 si iti dau pe privat. Nu prea ma descurc la explicat deci sper sa intelegi ce am vrut sa iti explic :)❤️ 

  • Upvote 1
Link to comment
Share on other sites

1 hour ago, Toader Mihai said:

function SendAdminMessage(color,const string[],level) {
    foreach(new i : Player) if(PlayerInfo[i][pAdmin] >= level) SendClientMessage(i, color, string);
    return 1;
}

mi se pare mai simplu.

Da, stiu ce zici, dar eu am incercat sa ii fac comanda pentru a putea folosi si args in string :)❤️ Este mai simpla varianta ta intr-adevar :)

Link to comment
Share on other sites


new Iterator: Iterator_Admins<MAX_PLAYERS>;

public OnPlayerConnect(playerid)
{
	if(PlayerInfo[playerid][pAdmin] > 0) Iter_Add(Iterator_Admin, playerid);
}

stock SendToAdmins(color, msg[])
{
	foreach(new i : Iterator_Admins) {
		if(PlayerInfo[i][pAdmin] > 0) {
			SCM(i, color, msg);
		}
	}
	return 1;
}

CMD:test(playerid)
{	
	SendToAdmins(-1, "Test");
	return 1;
}

Edit: Stergi verificarea (if(PlayerInfo[i][pAdmin] > 0) din stock-ul SendToAdmins. 
Am pus-o fara rost, se verifica deja odata la onplayerconnect.

Edited by Venombrk
Link to comment
Share on other sites

#include <a_samp>
#include <YSI_Data\y_iterate>


#define MAX_ADMIN_LEVEL 	7

new Iterator:AdminStaff<MAX_ADMIN_LEVEL +1, MAX_PLAYERS>;

public OnPlayerConnect(playerid) {
	Iter_Add(AdminStaff<7>, playerid); // 7 fiind admin level.
 	return true;
}

public OnPlayerDisconnect(playerid) {
	if(Iter_Contains(AdminStaff<7>, playerid)) Iter_Remove(AdminStaff<7>, playerid);
	return true;
}

#define sendAdminMessageF(%0,%1,%2,%3) \
	format(srsString,sizeof srsString,%1,%3)&&sendAdminMessage(%0,srsString,%2)

#define sendAdminMessageForAllF(%0,%1,%2,%3) \
	format(srsString,sizeof srsString,%1,%3)&&sendAdminMessageForAll(%0,srsString)

stock sendAdminMessage(const color, const message[], level) { // atentie sa nu treaca peste level-ul peste MAX_ADMIN_LEVEL!
	foreach(new a: AdminStaff<level>) SendClientMessage(a,color,message);
	return true;
}

stock sendAdminMessageForAll(const color, const message[]) {
	foreach(new a: All(AdminStaff<>)) SendClientMessage(a,color,message);
	return true;
}

poti interca si aici un exemplu facut de mine. :D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.