[HELP] Code appeares to be fine but not work!
#1

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;
}
Reply
#2

Код:
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.
Reply
#3

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.
Reply
#4

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?
Reply
#5

any help pls?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)