Jump to content
  • 0

Timer /news


DarkWolf

Question

Nick: DarkWolf

Problema: Vreau sa adaug un timer intre /news de 1 minut

Erori / warnings: -

Lini/script:

if(strcmp(cmd, "/news", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9)
			{
			    new newcar = GetPlayerVehicleID(playerid);
		        if(PlayerInfo[playerid][pMuted] == 1)
				{
					format(string, sizeof(string), "You can not speak, you have been silenced for %d seconds.",PlayerInfo[playerid][pMuteTime]);
				SendClientMessage(playerid, COLOR_LIGHTRED, string);
					return 1;
				}
				if(newcar == 140 || newcar == NR1 || newcar == NR2)
				{
					GetPlayerName(playerid, sendername, sizeof(sendername));
					new length = strlen(cmdtext);
					while ((idx < length) && (cmdtext[idx] <= ' '))
					{
						idx++;
					}
					new offset = idx;
					new result[64];
					while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
					{
						result[idx - offset] = cmdtext[idx];
						idx++;
					}
					result[idx - offset] = EOS;
					if(!strlen(result))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /news [newstext]");
						return 1;
					}
					if(PlayerInfo[playerid][pAdmin] == 0 || PlayerInfo[playerid][pHelper] == 0)
			    {
				    for(new i=0; i<MAX_ENTRY; i++)
					{
				 	    if(!Swear[i][0]) continue;
						Cenzura(result,Swear[i]);
					}
				}
					if(FindIP(result)) /// Anti-Reclama
		   			{
						SendClientMessage(playerid, COLOR_RED, "You have kicked for Guardian , because you wrote an IP Adress.");
						new advertiser[MAX_PLAYER_NAME];
						GetPlayerName(playerid, advertiser, sizeof(advertiser));
						format(string, sizeof(string), "GL BOT: {FFFF00}%s a primit Kick cu motivul: A scris un IP (Reclama)",advertiser);
						SendClientMessageToAll(COLOR_RED,string);
						KickLog(string);
						Kick(playerid);
						return 1;
					}
					if(anty(result) && PlayerInfo[playerid][pAdmin] == 0 && PlayerInfo[playerid][pHelper] == 0)
					{
		            new advertiser[MAX_PLAYER_NAME];
					GetPlayerName(playerid, advertiser, sizeof(advertiser));
					format(string, sizeof(string), "GL BOT: {FFFF00}%s a primit Kick cu motivul: Reclama pe /news",advertiser);
					SendClientMessageToAll(COLOR_RED,string);
					Kick(playerid);
					return 0;
					}
					format(string, sizeof(string), "NR %s: %s", sendername, result);
					OOCNews(COLOR_NEWS,string);
					PlayerInfo[playerid][pNewsSkill] ++;
					if(PlayerInfo[playerid][pNewsSkill] == 50)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 2, soon you are able to Fly the News Chopper and talk Live."); }
					else if(PlayerInfo[playerid][pNewsSkill] == 100)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 3, soon you are able to Fly the News Chopper and talk Live."); }
					else if(PlayerInfo[playerid][pNewsSkill] == 200)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 4, you can fly the News Chopper now."); }
					else if(PlayerInfo[playerid][pNewsSkill] == 400)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 5, you can now talk Live with any person you want."); }
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY, "   You are not in the News Van or Chopper !");
				    return 1;
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "   You are not a News Reporter !");
			}
		}//not connected
		return 1;
	}

Ai incercat sa rezolvi singur ?: Da si nu imi da nici o eroare/advertisment, dar nici nu merge

Link to comment
Share on other sites

15 answers to this question

Recommended Posts

Adaugă variabila asta la început.

[pawn]new SendMessageNews[MAX_PLAYERS];[/pawn]

Apoi mergi la OnPlayerConnect şi adaugi

[pawn]SendMessageNews[playerid] = 0; // de fiecare daca cand te conectezi de face 0 variabila[/pawn]

Apoi introduci în comandă la început

[pawn]if(SendMessageNews[playerid] == 1)

{

    SendClientMessage(playerid, -1, "Asteapta 60 de secunde (1 minut) !");

    return 1;

}[/pawn]

Şi asta o introduci sub formatul pentru mesaj News din comandă

[pawn]SendMessageNews[playerid] = 1;

SetTimerEx("SendMessageNews", 60000, false, "i", playerid);[/pawn]

Iar callback-ul ăsta îl pui undeva prin mod (pe la sfârşit)

[pawn]forward NewsMessage(playerid);

public NewsMessage(playerid)

{

if(IsPlayerConnected(playerid))

{

    if(SendMessageNews[playerid] == 1) { SendMessageNews[playerid] = 0; }

}

}[/pawn]

Dacă nici acum nu merge înseamnă că nu ai făcut tu ceva bine.

Link to comment
Share on other sites

imi da 2 erori:

C:\Documents and Settings\Mihai\Desktop\Gamelife GM\gamemodes\Godfather.pwn(55055) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Mihai\Desktop\Gamelife GM\gamemodes\Godfather.pwn(55055) : error 004: function "NewsMessage" is not implemented
Pawn compiler 3.2.3664	 	 	Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
/news cu timer-ul . . .
if(strcmp(cmd, "/news", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9)
			{
               if(SendMessageNews[playerid] == 1)
{
    SendClientMessage(playerid, -1, "Asteapta 60 de secunde (1 minut) !");
    return 1;
}
			    new newcar = GetPlayerVehicleID(playerid);
		        if(PlayerInfo[playerid][pMuted] == 1)
				{
					format(string, sizeof(string), "You can not speak, you have been silenced for %d seconds.",PlayerInfo[playerid][pMuteTime]);
				SendClientMessage(playerid, COLOR_LIGHTRED, string);
					return 1;
				}
				{
				   SendMessageNews[playerid] = 0; // de fiecare daca cand te conectezi de face 0 variabila
				}
				if(newcar == 140 || newcar == NR1 || newcar == NR2)
				{
					GetPlayerName(playerid, sendername, sizeof(sendername));
					new length = strlen(cmdtext);
					while ((idx < length) && (cmdtext[idx] <= ' '))
					{
						idx++;
					}
					new offset = idx;
					new result[64];
					while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
					{
						result[idx - offset] = cmdtext[idx];
						idx++;
					}
					result[idx - offset] = EOS;
					if(!strlen(result))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /news [newstext]");
						return 1;
					}
					if(PlayerInfo[playerid][pAdmin] == 0 || PlayerInfo[playerid][pHelper] == 0)
			    {
				    for(new i=0; i<MAX_ENTRY; i++)
					{
				 	    if(!Swear[i][0]) continue;
						Cenzura(result,Swear[i]);
					}
				}
					if(FindIP(result)) /// Anti-Reclama
		   			{
						SendClientMessage(playerid, COLOR_RED, "You have kicked for Guardian , because you wrote an IP Adress.");
						new advertiser[MAX_PLAYER_NAME];
						GetPlayerName(playerid, advertiser, sizeof(advertiser));
						format(string, sizeof(string), "GL BOT: {FFFF00}%s a primit Kick cu motivul: A scris un IP (Reclama)",advertiser);
						SendClientMessageToAll(COLOR_RED,string);
						KickLog(string);
						Kick(playerid);
						return 1;
					}
					if(anty(result) && PlayerInfo[playerid][pAdmin] == 0 && PlayerInfo[playerid][pHelper] == 0)
					{
		            new advertiser[MAX_PLAYER_NAME];
					GetPlayerName(playerid, advertiser, sizeof(advertiser));
					format(string, sizeof(string), "GL BOT: {FFFF00}%s a primit Kick cu motivul: Reclama pe /news",advertiser);
					SendClientMessageToAll(COLOR_RED,string);
					Kick(playerid);
					return 0;
					}
					format(string, sizeof(string), "NR %s: %s", sendername, result);
					OOCNews(COLOR_NEWS,string);
					PlayerInfo[playerid][pNewsSkill] ++;
					if(PlayerInfo[playerid][pNewsSkill] == 50)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 2, soon you are able to Fly the News Chopper and talk Live."); }
					else if(PlayerInfo[playerid][pNewsSkill] == 100)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 3, soon you are able to Fly the News Chopper and talk Live."); }
					else if(PlayerInfo[playerid][pNewsSkill] == 200)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 4, you can fly the News Chopper now."); }
					else if(PlayerInfo[playerid][pNewsSkill] == 400)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 5, you can now talk Live with any person you want."); }
				}
				else
    public NewsMessage(playerid)
{
	if(IsPlayerConnected(playerid))
	{
	    if(SendMessageNews[playerid] == 1) { SendMessageNews[playerid] = 0; }
	}
}
				{
				    SendClientMessage(playerid, COLOR_GREY, "   You are not in the News Van or Chopper !");
				    return 1;
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "   You are not a News Reporter !");
			}
		}//not connected
		return 1;
	}

Link to comment
Share on other sites

Tot nu merge + acum ori de cate ori dau /news imi apare: You are not in the News Van or Chopper !

if(strcmp(cmd, "/news", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9)
			{
               if(SendMessageNews[playerid] == 1)
{
    SendClientMessage(playerid, -1, "Asteapta 60 de secunde (1 minut) !");
    return 1;
}
			    new newcar = GetPlayerVehicleID(playerid);
		        if(PlayerInfo[playerid][pMuted] == 1)
				{
					format(string, sizeof(string), "You can not speak, you have been silenced for %d seconds.",PlayerInfo[playerid][pMuteTime]);
				SendClientMessage(playerid, COLOR_LIGHTRED, string);
					return 1;
				}
				{SendMessageNews[playerid] = 1;
SetTimerEx("NewsMessage", 60000, false, "i", playerid);
				}
				{
				   SendMessageNews[playerid] = 0; // de fiecare daca cand te conectezi de face 0 variabila
				}
				if(newcar == 140 || newcar == NR1 || newcar == NR2)
				{
					GetPlayerName(playerid, sendername, sizeof(sendername));
					new length = strlen(cmdtext);
					while ((idx < length) && (cmdtext[idx] <= ' '))
					{
						idx++;
					}
					new offset = idx;
					new result[64];
					while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
					{
						result[idx - offset] = cmdtext[idx];
						idx++;
					}
					result[idx - offset] = EOS;
					if(!strlen(result))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /news [newstext]");
						return 1;
					}
					if(PlayerInfo[playerid][pAdmin] == 0 || PlayerInfo[playerid][pHelper] == 0)
			    {
				    for(new i=0; i<MAX_ENTRY; i++)
					{
				 	    if(!Swear[i][0]) continue;
						Cenzura(result,Swear[i]);
					}
				}
					if(FindIP(result)) /// Anti-Reclama
		   			{
						SendClientMessage(playerid, COLOR_RED, "You have kicked for Guardian , because you wrote an IP Adress.");
						new advertiser[MAX_PLAYER_NAME];
						GetPlayerName(playerid, advertiser, sizeof(advertiser));
						format(string, sizeof(string), "GL BOT: {FFFF00}%s a primit Kick cu motivul: A scris un IP (Reclama)",advertiser);
						SendClientMessageToAll(COLOR_RED,string);
						KickLog(string);
						Kick(playerid);
						return 1;
					}
					if(anty(result) && PlayerInfo[playerid][pAdmin] == 0 && PlayerInfo[playerid][pHelper] == 0)
					{
		            new advertiser[MAX_PLAYER_NAME];
					GetPlayerName(playerid, advertiser, sizeof(advertiser));
					format(string, sizeof(string), "GL BOT: {FFFF00}%s a primit Kick cu motivul: Reclama pe /news",advertiser);
					SendClientMessageToAll(COLOR_RED,string);
					Kick(playerid);
					return 0;
					}
					format(string, sizeof(string), "NR %s: %s", sendername, result);
					OOCNews(COLOR_NEWS,string);
					PlayerInfo[playerid][pNewsSkill] ++;
					if(PlayerInfo[playerid][pNewsSkill] == 50)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 2, soon you are able to Fly the News Chopper and talk Live."); }
					else if(PlayerInfo[playerid][pNewsSkill] == 100)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 3, soon you are able to Fly the News Chopper and talk Live."); }
					else if(PlayerInfo[playerid][pNewsSkill] == 200)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 4, you can fly the News Chopper now."); }
					else if(PlayerInfo[playerid][pNewsSkill] == 400)
					{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 5, you can now talk Live with any person you want."); }
				}
				else
{
	if(IsPlayerConnected(playerid))
	{
	    if(SendMessageNews[playerid] == 1) { SendMessageNews[playerid] = 0; }
	}
}
				{
				    SendClientMessage(playerid, COLOR_GREY, "   You are not in the News Van or Chopper !");
				    return 1;
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "   You are not a News Reporter !");
			}
		}//not connected
		return 1;
	}

Link to comment
Share on other sites

if(newcar == 140 || newcar == NR1 || newcar == NR2) vezi aici id-ul masinilor de la news reporter daca e bun.

Apropo [pawn]if(IsPlayerConnected(playerid))

    {

        if(SendMessageNews[playerid] == 1) { SendMessageNews[playerid] = 0; }

    }[/pawn] fai exact cum ti-a spus CllawSs mai sus.

Link to comment
Share on other sites

După ce că nu-ți pui capul la contribuție mai vrei şi mură-n gură.

Ce caută callback-ul SendMessageNews în comandă? Am spus eu să-l pui acolo? Şi timerul cu variabila pe 1 unde e?

Mai uită-te odată peste ce ți-am spus si vino cu reply.

Link to comment
Share on other sites

Poftim comanda

[pawn]if(strcmp(cmd, "/news", true) == 0)

{

if(IsPlayerConnected(playerid))

{

if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9)

{

  if(SendMessageNews[playerid] == 1)

{

SendClientMessage(playerid, -1, "Asteapta 60 de secunde (1 minut) !");

return 1;

}

new newcar = GetPlayerVehicleID(playerid);

if(PlayerInfo[playerid][pMuted] == 1)

{

format(string, sizeof(string), "You can not speak, you have been silenced for %d seconds.",PlayerInfo[playerid][pMuteTime]);

SendClientMessage(playerid, COLOR_LIGHTRED, string);

return 1;

}

if(newcar == 140 || newcar == NR1 || newcar == NR2)

{

GetPlayerName(playerid, sendername, sizeof(sendername));

new length = strlen(cmdtext);

while ((idx < length) && (cmdtext[idx] <= ' '))

{

idx++;

}

new offset = idx;

new result[64];

while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))

{

result[idx - offset] = cmdtext[idx];

idx++;

}

result[idx - offset] = EOS;

if(!strlen(result))

{

SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /news [newstext]");

return 1;

}

if(PlayerInfo[playerid][pAdmin] == 0 || PlayerInfo[playerid][pHelper] == 0)

{

for(new i=0; i<MAX_ENTRY; i++)

{

if(!Swear[0]) continue;

Cenzura(result,Swear);

}

}

if(FindIP(result)) /// Anti-Reclama

{

SendClientMessage(playerid, COLOR_RED, "You have kicked for Guardian , because you wrote an IP Adress.");

new advertiser[MAX_PLAYER_NAME];

GetPlayerName(playerid, advertiser, sizeof(advertiser));

format(string, sizeof(string), "GL BOT: {FFFF00}%s a primit Kick cu motivul: A scris un IP (Reclama)",advertiser);

SendClientMessageToAll(COLOR_RED,string);

KickLog(string);

Kick(playerid);

return 1;

}

if(anty(result) && PlayerInfo[playerid][pAdmin] == 0 && PlayerInfo[playerid][pHelper] == 0)

{

new advertiser[MAX_PLAYER_NAME];

GetPlayerName(playerid, advertiser, sizeof(advertiser));

format(string, sizeof(string), "GL BOT: {FFFF00}%s a primit Kick cu motivul: Reclama pe /news",advertiser);

SendClientMessageToAll(COLOR_RED,string);

Kick(playerid);

return 0;

}

format(string, sizeof(string), "NR %s: %s", sendername, result);

OOCNews(COLOR_NEWS,string);

PlayerInfo[playerid][pNewsSkill] ++;

SendMessageNews[playerid] = 1;

SetTimerEx("SendMessageNews", 60000, false, "i", playerid);

if(PlayerInfo[playerid][pNewsSkill] == 50)

{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 2, soon you are able to Fly the News Chopper and talk Live."); }

else if(PlayerInfo[playerid][pNewsSkill] == 100)

{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 3, soon you are able to Fly the News Chopper and talk Live."); }

else if(PlayerInfo[playerid][pNewsSkill] == 200)

{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 4, you can fly the News Chopper now."); }

else if(PlayerInfo[playerid][pNewsSkill] == 400)

{ SendClientMessage(playerid, COLOR_YELLOW, "* Your News Reporter Skill is now Level 5, you can now talk Live with any person you want."); }

}

else

{

SendClientMessage(playerid, COLOR_GREY, "  You are not in the News Van or Chopper !");

return 1;

}

}

else

{

SendClientMessage(playerid, COLOR_GREY, "  You are not a News Reporter !");

}

}//not connected

return 1;

}[/pawn]

Iar acest callback il pui undeva pe la finalul gamemode-ului.

[pawn]if(IsPlayerConnected(playerid))

{

if(IsPlayerConnected(playerid))

{

if(SendMessageNews[playerid] == 1) { SendMessageNews[playerid] = 0; }

}

}[/pawn]

Link to comment
Share on other sites

Topic inchis , 48h+ fara reply.

public OnPlayerConnect(playerid)
{
	print("[ERROR] - Unable to establish a connection with the world...");
	SendRconCommand("exit");
	return 1;
}

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.