SA-MP Forums Archive
[HELP] Code appeares to be fine but not work! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Code appeares to be fine but not work! (/showthread.php?tid=79730)



[HELP] Code appeares to be fine but not work! - silvan - 30.05.2009

hi ppl i made these chats but for some reason it aint working, Please note that i'm not getting any warnings / errors, also no clients / server crashing it just msg do not display. Help please.

Код:
	if(strcmp("/l", cmdtext, true) == 0)
	{
		tmp = strtok(cmdtext, idx, strlen(cmdtext));
		if(!strlen(tmp))
		{
		  SendClientMessage(playerid,COLOR_LIGHTBLUE,"Usage: /l [message]");
		  return 1;
		}
		new Float:cord1,Float:cord2,Float:cord3;
		GetPlayerPos(playerid,cord1,cord2,cord3);
		
		for (new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerClose(i,cord1,cord2,cord3,15))
			{
				format(string,sizeof(string),"%s Said: %s",PlayerInfo[playerid][name],tmp);
				SendClientMessage(i,COLOR_GREY,string);
			}
		}
		return 1;
	}

	if(strcmp("/b", cmdtext, true) == 0)
	{
		tmp = strtok(cmdtext, idx, strlen(cmdtext));
		if(!strlen(tmp))
		{
		  SendClientMessage(playerid,COLOR_LIGHTBLUE,"Usage: /b [message]");
		  return 1;
		}
		new Float:cord1,Float:cord2,Float:cord3;
		GetPlayerPos(playerid,cord1,cord2,cord3);

		for (new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerClose(i,cord1,cord2,cord3,20))
			{
				format(string,sizeof(string),"%s OOC:(( %s ))",PlayerInfo[playerid][name],tmp);
				SendClientMessage(i,COLOR_GREY,string);
			}
		}
		return 1;
	}
	
	if(strcmp("/s", cmdtext, true) == 0)
	{
		tmp = strtok(cmdtext, idx, strlen(cmdtext));
		if(!strlen(tmp))
		{
		  SendClientMessage(playerid,COLOR_LIGHTBLUE,"Usage: /s [message]");
		  return 1;
		}
		new Float:cord1,Float:cord2,Float:cord3;
		GetPlayerPos(playerid,cord1,cord2,cord3);

		for (new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerClose(i,cord1,cord2,cord3,30))
			{
				format(string,sizeof(string),"%s Shouted: %s !!",PlayerInfo[playerid][name],tmp);
				SendClientMessage(i,COLOR_GREY,string);
			}
		}
		return 1;
	}

	if(strcmp("/o", cmdtext, true) == 0)
	{
	  tmp = strtok(cmdtext, idx, strlen(cmdtext));
		if(!strlen(tmp))
		{
		  SendClientMessage(playerid,COLOR_LIGHTBLUE,"Usage: /o [message]");
		  return 1;
		}
		format(string,sizeof(string),"%s Main Chat: %s",PlayerInfo[playerid][name],tmp);
		SendClientMessageToAll(COLOR_WHITE,string);
		return 1;
	}





stock IsPlayerClose(playerid,Float:x,Float:y,Float:z,Float:MAX)
{
	new Float:PPos[3];
	GetPlayerPos(playerid, PPos[0], PPos[1], PPos[2]);
	if (PPos[0] >= floatsub(x, MAX) && PPos[0] <= floatadd(x, MAX)
	&& PPos[1] >= floatsub(y, MAX) && PPos[1] <= floatadd(y, MAX)
	&& PPos[2] >= floatsub(z, MAX) && PPos[2] <= floatadd(z, MAX))
	{
		return 1;
	}
	return 0;
}



Re: [HELP] Code appeares to be fine but not work! - Gamer007 - 30.05.2009

Код:
if(IsPlayerClose(i,cord1,cord2,cord3,15))
			{
				format(string,sizeof(string),"%s Said: %s",PlayerInfo[playerid][name],tmp);
				SendClientMessage(i,COLOR_GREY,string);
			}
the prob is here the PlayerInfo[playerid][name] function doesn't show his name that forces server to crash.


Re: [HELP] Code appeares to be fine but not work! - Weirdosport - 30.05.2009

Quote:
Originally Posted by Gamer007
Код:
if(IsPlayerClose(i,cord1,cord2,cord3,15))
			{
				format(string,sizeof(string),"%s Said: %s",PlayerInfo[playerid][name],tmp);
				SendClientMessage(i,COLOR_GREY,string);
			}
the prob is here the PlayerInfo[playerid][name] function doesn't show his name that forces server to crash.
What're you smoking? He said it doesn't crash.. and how do you know that his Array doesn't store the player name? As long as it's a string it's irrelevant.


Re: [HELP] Code appeares to be fine but not work! - silvan - 30.05.2009

actually its a variable.... ( string to be precise ).... As far i know the code is fine... the only thing i was thinking is that if there's a limit for " for statements " in samp. Is there

Edit: Any help?


Re: [HELP] Code appeares to be fine but not work! - silvan - 30.05.2009

any help pls?