isplayerinrangeofpoint & else if not
#1

Код:
if (strcmp("/open police", cmdtext, true, 10) == 0)
	{
	    if(GetPlayerSkin(playerid)!=280) return SendClientMessage(playerid, COLOR_ERROR,"You are not a cop");
  IsPlayerInRangeOfPoint(playerid, 3.0, 1151.2433,-1226.3589,17.2747);
		{
		    else if(IsPlayerInRangeOfPoint(playerid, 3.0, 1151.2433,-1226.3589,17.2747);)
		    {
		        SendClientMessage(playerid, COLOR_RED, "You are not near the gate.");
			}
  	  MoveDynamicObject(copgate, 1151.3508, -1222.7382, 9.6951, 3);
		SendClientMessage(playerid, COLOR_BLUE, "Gate: Opened.");
		return 1;
	}
so like, everything works how it should, I just don't know how to make so if a player is not inrangeof point, it should say to him: you are not near the gate instead of Gate:Open but the gate actually didn't open itself, how can i fix this?
Reply
#2

Код:
if (strcmp("/open police", cmdtext, true, 10) == 0)
	{
	    if(GetPlayerSkin(playerid)!=280) return SendClientMessage(playerid, COLOR_ERROR,"You are not a cop");
  if(IsPlayerInRangeOfPoint(playerid, 3.0, 1151.2433,-1226.3589,17.2747))
		{
		    
  	  MoveDynamicObject(copgate, 1151.3508, -1222.7382, 9.6951, 3);
		SendClientMessage(playerid, COLOR_BLUE, "Gate: Opened.");
		return 1;
	}
        else if(!IsPlayerInRangeOfPoint(playerid, 3.0, 1151.2433,-1226.3589,17.2747))
		    {
		        SendClientMessage(playerid, COLOR_RED, "You are not near the gate.");
                        return 1;
			}
Reply
#3

PHP код:
if (strcmp("/open police"cmdtexttrue10) == 0)
{
    if (
GetPlayerSkin(playerid) != 280
        return 
SendClientMessage(playeridCOLOR_ERROR, !"You are not a cop");
    if(!
IsPlayerInRangeOfPoint(playerid3.01151.2433, -1226.358917.2747))
        return 
SendClientMessage(playeridCOLOR_RED, !"You are not near the gate.");
    
MoveDynamicObject(swatgate1151.3508, -1222.73829.69513);
    return 
SendClientMessage(playeridCOLOR_BLUE, !"Gate: Opened.");

Reply
#4

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
Код:
if (strcmp("/open police", cmdtext, true, 10) == 0)
	{
	    if(GetPlayerSkin(playerid)!=280) return SendClientMessage(playerid, COLOR_ERROR,"You are not a cop");
  if(IsPlayerInRangeOfPoint(playerid, 3.0, 1151.2433,-1226.3589,17.2747))
		{
		    
  	  MoveDynamicObject(copgate, 1151.3508, -1222.7382, 9.6951, 3);
		SendClientMessage(playerid, COLOR_BLUE, "Gate: Opened.");
		return 1;
	}
        else if(!IsPlayerInRangeOfPoint(playerid, 3.0, 1151.2433,-1226.3589,17.2747))
		    {
		        SendClientMessage(playerid, COLOR_RED, "You are not near the gate.");
                        return 1;
			}
fail cod -_-
Reply
#5

Try this:

PHP код:
if(strcmp("/open police"cmdtexttrue10) == 0)
{
    if(
GetPlayerSkin(playerid)!=280) return SendClientMessage(playeridCOLOR_ERROR,"You are not a cop");
    if(
IsPlayerInRangeOfPoint(playerid3.01151.2433,-1226.3589,17.2747));
    {
        
MoveDynamicObject(copgate1151.3508, -1222.73829.69513);
        
SendClientMessage(playeridCOLOR_BLUE"Gate: Opened.");
    }
    else
    {
         
SendClientMessage(playeridCOLOR_RED"You are not near the gate.");
    }
    return 
1;

And read this: https://sampwiki.blast.hk/wiki/Control_Structures#else
and this: https://sampwiki.blast.hk/wiki/Control_Structures#else_if
Reply
#6

Quote:
Originally Posted by DarkLored
Посмотреть сообщение
Код:
if (strcmp("/open police", cmdtext, true, 10) == 0)
	{
	    if(GetPlayerSkin(playerid)!=280) return SendClientMessage(playerid, COLOR_ERROR,"You are not a cop");
  if(IsPlayerInRangeOfPoint(playerid, 3.0, 1151.2433,-1226.3589,17.2747))
		{
		    
  	  MoveDynamicObject(copgate, 1151.3508, -1222.7382, 9.6951, 3);
		SendClientMessage(playerid, COLOR_BLUE, "Gate: Opened.");
		return 1;
	}
        else if(!IsPlayerInRangeOfPoint(playerid, 3.0, 1151.2433,-1226.3589,17.2747))
		    {
		        SendClientMessage(playerid, COLOR_RED, "You are not near the gate.");
                        return 1;
			}
Quote:
Originally Posted by Andre02
Посмотреть сообщение
Try this:

PHP код:
if(strcmp("/open police"cmdtexttrue10) == 0)
{
    if(
GetPlayerSkin(playerid)!=280) return SendClientMessage(playeridCOLOR_ERROR,"You are not a cop");
    if(
IsPlayerInRangeOfPoint(playerid3.01151.2433,-1226.3589,17.2747));
    {
        
MoveDynamicObject(copgate1151.3508, -1222.73829.69513);
        
SendClientMessage(playeridCOLOR_BLUE"Gate: Opened.");
    }
    else
    {
         
SendClientMessage(playeridCOLOR_RED"You are not near the gate.");
    }
    return 
1;

And read this: https://sampwiki.blast.hk/wiki/Control_Structures#else
and this: https://sampwiki.blast.hk/wiki/Control_Structures#else_if
But what you are not satisfied with my code?
Reply
#7

Quote:
Originally Posted by kennydalglish
Посмотреть сообщение
But what you are not satisfied with my code?
Wow chill down dude, we are trying to help him out..

I was fixing his indentation and puting the code he wanted, during that time i didn't see you posted, so just calm down...

+ if you know how to read i also added some more things.
Reply
#8

Thank you, I tried Andre02's and it worked. Thanks all of you, but one problem;
By the way; look at this, please: http://s18.postimg.org/4dijx7id5/swat.png
So, there is a gate, and in 'open' coordinate; 1151.2433,-1226.3589,17.2747
I cannot open the gate inside the base where 'close' position is saved, I can only close; same goes if you turn it vice versa; I cannot from 'close' coordinate: 1151.0093,-1220.3475,17.8860 open the base, I can only close it;
can someone tell me how can I make, so with one command, such as /cop for example; I can open/close inside and outside the gate/base?
Reply
#9

To help you learn, check to see if the player is at either position (open/close). Then get the objects position. is the object in the opened position, or is the object in the closed position. Then, move the object to the opposite position depending on the current position of the object.

Or, just set a variable to the gate (Opened = true/false) and check for that variable upon using "/cop".
Reply
#10

If I wasn't clear;
e.g.: i want to leave the base(I scripted so you can only close the base when you're inside of it and you can open when you outside of it, which means when I want to go to the base) so i also want the vice versa;
When I want to go out of the base, in the 'close' coordinate, I can open and get out of it, and when I come back(I can only open it) I want to close the gate as I don't want any other people to enter in it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)