Three different problems - Hard to explain
#1

My first problem is whenever I try to send a message to only admins it sends it to everyone, and multiple times. For example, when an admin gives a player a gun it's supposed to do this;
Код:
for(new i=0; i < MAX_PLAYERS; i++)
		{
	    	new alert[256], pname[64], aname[64];
			new aid = GetPlayerID(playerid, aname);
			new admins = PlayerInfo[i][pAdmin] > 0;
			GetPlayerName(id, pname, 64);
 			GetPlayerName(playerid, aname, 64);
	 	   	GetPlayerName(playerid, name, 24);
	    	GetPlayerName(id, name1, 24);
	    	format(string, sizeof(string), "Admin %s has given you weapon ID %d with %d ammo.", name, gun, ammo);
	    	SendClientMessage(id, COLOR_LIGHTGREEN, string);
	    	format(string1, sizeof(string1), "You have given %s weapon ID %d with %d ammo.", name1, gun, ammo);
	    	SendClientMessage(playerid, COLOR_LIGHTGREEN, string1);
			GivePlayerWeapon(id, gun, ammo);
			format(alert, 256, "[ADMIN CMD] (/agun) %s (%d) has given %s (%d) gun ID %d with %d ammo", aname, aid, pname, id, gun, ammo);
			SendClientMessage(admins, COLOR_LIGHTYELLOW2, alert);
			print(alert);
		}
Although instead of just sending the message once, it sends it about 15 times, and to EVERYONE. I've tried re-defining MAX_PLAYERS and just leaving it defined as it was, still does it both ways. This happens for every single other admin command, and some of the player command.

The second problem is that my give car command crashes my client (but not the server.)
Код:
CMD:acar(playerid, params[])
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    new vehicle = GetVehicleModelIDFromName(params);
	    if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_GREY, "Sorry, you aren't an admin!");
		if(PlayerInfo[playerid][pAdmin] == 1 || PlayerInfo[playerid][pAdmin] == 2) return SendClientMessage(playerid, COLOR_GREY, "Your admin level isn't high enough!");
		if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid, COLOR_GREY, "That vehicle name was not found!");
		new Float:a, Float:x, Float:y, Float:z, string[256], alert[256], name[64];
		GetPlayerFacingAngle(playerid, a);
		GetPlayerPos(playerid, x, y, z);
		GetPlayerName(playerid, name, 64);
		if(IsPlayerInAnyVehicle(playerid) == 1) GetXYInFrontOfPlayer(playerid, x, y, 8);
		else GetXYInFrontOfPlayer(playerid, x, y, 5);
		new pveh = CreateVehicle(vehicle, x, y, z, a+90, 177, 177, -1);
		new admins = PlayerInfo[playerid][pAdmin] > 0;
		LinkVehicleToInterior(pveh, GetPlayerInterior(playerid));
		format(alert, 256, "[ADMIN ALERT] (/acar) %s (%d) has spawned a vehicle ID (%d)", name, playerid, GetVehicleModelIDFromName(params));
		SendClientMessage(admins, COLOR_LIGHTYELLOW2, alert);
		format(string, 256, "You have spawned a vehicle.");
		SendClientMessage(playerid, COLOR_GREEN, string);
	 	print(alert);
	}
	return 1;
}
It spams my chat with the 'You have spawned a vehicle.' message and then crashes my client.

My third problem is hard to use words, so I'll just show you;
Код:
new File:cmdlog = fopen("/logs/commands.log", io_write);
new File:admlog = fopen("/logs/admins.log", io_write);
new File:connectlog = fopen("/logs/connections.log", io_write);
new File:icchatlog = fopen("/logs/icchat.log", io_write);
new File:oocchatlog = fopen("/logs/oocchat.log", io_write);
Whenever I uncomment that (it's commented out right now) is crashes Pawno Compiler. I don't see any extra brackets, and it's at the top few hundred lines of my script.

Any and all help is GREATLY appreciated. I'm having a hard enough time scripting as it is, with the problems it's even harder.
Reply
#2

Код:
stock SendClientMessageToAdmins(color, message[])
{
foreach (i : Player)
{
   if(PlayerInfo[i][pAdmin] > 0)
   {
      SendClientMessage(i, color, message);
   }
}
return 1;
}
You can use something like this to send messages to admins, for solving your first problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)