SA-MP Forums Archive
Moving gate open and close - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Moving gate open and close (/showthread.php?tid=466410)



Moving gate open and close - SFA7X - 27.09.2013

Hello,The problem is that it opens but doesn't close. like when i type /opensfa7house ,it opens the door but when i type /closesfa7house ,nothing happens
please help me,
CodeIs:

#include <a_samp>

#define FILTERSCRIPT
new sfa7house;

public OnFilterScriptInit()
{
sfa7house = CreateObject(980, 249.21007, -1760.01697, 7.74010, 0.00000, 0.00000, 0.00000, 100.0);
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/opensfa7house", true)){
MoveObject(sfa7house, 0, 0, 0, 3.0, 0.0, 0.0, 0.0);
return 1;
}
else if(strcmp(cmdtext, "/closesfa7house", true)){
MoveObject(sfa7house, 249.21007, -1760.01697, 7.74010, 0.00000, 0.00000, 0.00000, 100.0);
return 1;
}
return 0;
}
public OnFilterScriptExit()
{
return 1;
}


Re: Moving gate open and close - Mattakil - 27.09.2013

don't use "else"..also, why does it move the object to coords "0,0,0" then to 249.21007, -1760.01697, 7.74010?

On the open command the speed is also not set?

I reckon using zcmd and doing it like this

pawn Код:
CMD:open(playerid, params[])
{
if(sscanf(params, "open", params)
{
if(IsPlayerInRangeOfPoint(whatever)
{
//open object
}
if(sscanf(params, "close", params)
{
if(IsPlayerInRangeOfPoint(whatever)
{
//close object
}
This will give you one command for all your gates (open, close)..Just add a new "ifisplayerinrangeofpoint" for every new gate, it also uses zcmd and sscanf2, which are two includes every good scripter uses (and not so good :S) Drop me a PM if you wish me to give further assistance.

NOTE: This is a demo, notice the lack of indentations, and I think I left out a few closing braces