Need help in code
#1

Hello for all, I have one problem.
I took one gamemode fro forum, but there is one proble, when cia is in checkpoint you need to type id of player you want to view, and it's made like dialog,but the problem is that the player who is using satelit can view(spectate) himself . How can I stop that. What I need to put?

Код:
if(dialogid == DIALOG_CIASAT)
	{
	    if(response == 1)
	    {
	        new ID =strval(inputtext);
	        if(!strlen(inputtext))
	        {
		        SendClientMessage(playerid,COLOR_ERROR,"Please enter the Player ID of the person you want to view.");
		        return 1;
			}
			if(!IsPlayerConnected(ID))
			{
			    SendClientMessage(playerid,COLOR_ERROR,"That Player ID is not connected to the server. Please enter the Player ID of the person you want to view.");
			    return 1;
			}
			if(IsSpawned[ID] != 1)
			{
			    SendClientMessage(playerid,COLOR_ERROR,"That Player ID is dead. Please enter the Player ID of the person you want to view.");
			    return 1;
			}
			if(JailTime[ID] >= 1)
			{
			    SendClientMessage(playerid,COLOR_ERROR,"That Player ID is in prison. Please enter the Player ID of the person you want to view.");
			    return 1;
			}
			if(IsPlayerInAnyVehicle(ID))
			{
				new sname[24];
				GetPlayerName(ID,sname,sizeof(sname));
			    new pveh =GetPlayerVehicleID(ID);
				CIAPlayerBeingViewed[playerid] =ID;
				CIAIsBeingWatched[ID] =1;

				for(new w=0; w<13; w++)
				{
		    		GetPlayerWeaponData(playerid,w,PlayerWeapon[playerid][w],PlayerAmmo[playerid][w]);
				}

				new pint = GetPlayerInterior(ID);
				SetPlayerInterior(playerid,pint);
				TogglePlayerSpectating(playerid,1);
				PlayerSpectateVehicle(playerid,pveh);

				SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_CIA Satelite Viewing_]]");
				format(string,sizeof(string),"You are now viewing %s(%d) through the CIA Satelite Imagery.",sname,ID);
				SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
				return 1;
			}
			if(!IsPlayerInAnyVehicle(ID))
			{
				new sname[24];
				GetPlayerName(ID,sname,sizeof(sname));
				CIAPlayerBeingViewed[playerid] =ID;
				CIAIsBeingWatched[ID] =1;

				for(new w=0; w<13; w++)
				{
		    		GetPlayerWeaponData(playerid,w,PlayerWeapon[playerid][w],PlayerAmmo[playerid][w]);
				}

				new pint = GetPlayerInterior(ID);
				SetPlayerInterior(playerid,pint);
				TogglePlayerSpectating(playerid,1);
				PlayerSpectatePlayer(playerid,ID);

				SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_CIA Satelite Viewing_]]");
				format(string,sizeof(string),"You are now viewing %s(%d) through the CIA Satelite Imagery.",sname,ID);
				SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
				return 1;
			}
			return 1;
		}
	}
Reply
#2

Compare if IDs are equals:
pawn Код:
if (ID == playerid)
{
    SendClientMessage(playerid,COLOR_ERROR,"You cannot use it on yourself. Please enter the Player ID of the person you want to view.");
    return 1;
}
Reply
#3

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Compare if IDs are equals:
pawn Код:
if (ID == playerid)
{
    SendClientMessage(playerid,COLOR_ERROR,"You cannot use it on yourself. Please enter the Player ID of the person you want to view.");
    return 1;
}
Oh yess, how I didn't remember that
Thanks a lot!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)