isplayerinrangeofpoint & else if not -
Aleksabre - 12.08.2015
Код:
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?
Re: isplayerinrangeofpoint & else if not -
DarkLored - 12.08.2015
Код:
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;
}
Re: isplayerinrangeofpoint & else if not -
kennydalglish - 12.08.2015
PHP код:
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))
return SendClientMessage(playerid, COLOR_RED, !"You are not near the gate.");
MoveDynamicObject(swatgate, 1151.3508, -1222.7382, 9.6951, 3);
return SendClientMessage(playerid, COLOR_BLUE, !"Gate: Opened.");
}
Re: isplayerinrangeofpoint & else if not -
kennydalglish - 12.08.2015
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 -_-
Re: isplayerinrangeofpoint & else if not -
Andre02 - 12.08.2015
Try this:
PHP код:
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.");
}
else
{
SendClientMessage(playerid, COLOR_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
Re: isplayerinrangeofpoint & else if not -
kennydalglish - 12.08.2015
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", 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.");
}
else
{
SendClientMessage(playerid, COLOR_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?
Re: isplayerinrangeofpoint & else if not -
Andre02 - 12.08.2015
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.
Re: isplayerinrangeofpoint & else if not -
Aleksabre - 13.08.2015
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?
Re: isplayerinrangeofpoint & else if not -
zDivine - 13.08.2015
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".
Re: isplayerinrangeofpoint & else if not -
Aleksabre - 13.08.2015
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.