All pastes #367960 Raw Edit

Untitled

public text v1 · immutable
#367960 ·published 2007-02-22 18:57 UTC
rendered paste body
	else if(strcmp(cmd,"/cjoin",true)==0)
	{
	    new room[256];
	    strmid(room,cmdtext,strlen(cmd)+1,strlen(cmdtext));
	    if(strlen(room)==0)
	    {
	        SendClientMessage(playerid,red,"Enter the name of the chatroom you want to enter!");
	    }
	    else
	    {
	        new output[256];
	        new name[256];
	        new opcheck=0;
	        GetPlayerName(playerid,name,sizeof(name));
	        if(strcmp(chat[playerid],"",false)!=0)
	        {
	            format(output,sizeof(output),"You have just left %s.",chat[playerid]);
	            SendClientMessage(playerid,gold,output);
	            format(output,sizeof(output),"%s has just left %s.",name,chat[playerid]);
	            for(new n=0;n<GetMaxPlayers();n++)
		        {
					if(IsPlayerConnected(n))
					{
					    if(strcmp(chat[n],chat[playerid],true)==0)
					    {
					        SendClientMessage(n,gold,output);
					    }
					}
		        }
		        chat[playerid]="";
	        }
	        for(new n=0;n<GetMaxPlayers();n++)
	        {
				if(IsPlayerConnected(n))
				{
				    if(strcmp(chat[n],room,true)==0 && ischatop[n]==1)
				    {
				        opcheck=1;
				    }
				}
	        }
	        if(opcheck==0)
	        {
	            ischatop[playerid]=1;
	        }
	        format(output,sizeof(output),"You have just entered \"%s\".",room);
	        SendClientMessage(playerid,gold,output);
	        for(new n=0;n<GetMaxPlayers();n++)
	        {
				if(IsPlayerConnected(n) && strcmp(chat[n],"",false)!=0)
				{
				    if(strcmp(chat[n],room,true)==0)
				    {
				    	format(output,sizeof(output),"%s has just entered \"%s\".",name,chat[n]);
				        SendClientMessage(n,gold,output);
				    }
				}
	        }
	        chat[playerid]=room;
	    }
		return 1;
	}

(...)

	if(text[0]=='#')
	{
	    if(strcmp(chat[playerid],"",false)==0)
	    {
	        SendClientMessage(playerid,red,"You are not in a chatroom! Use /cjoin ROOM to join one.");
		}
		else
		{
		    new name[256];
			new message[256];
		    new output[256];
		    GetPlayerName(playerid,name,sizeof(name));
	        strmid(message,text,1,strlen(text));
		    format(output,sizeof(output),"<CHAT> %s: %s",name,message);
		    for(new n=0;n<GetMaxPlayers();n++)
		    {
		        if(IsPlayerConnected(n))
		        {
		            if(strcmp(chat[n],chat[playerid],true)==0)
		            {
		                SendClientMessage(n,gold,output);
		            }
		        }
		    }
		}
		return 0;
	}