SetObjectRot |
forward rotation(); // The call back Timer.
public OnGameModeInit()
{
SetTimer("rotation", 100, 1); // The timer which will go off every millisecond.
object = CreateObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ); // The object (Fill in the spaces)
}
public rotation() // The callback
{
SetObjectRot(object, 0, 0, +0.1); // Will set the Z rot +0.1 every millisecond
return 1;
}
Originally Posted by Farly
Correct me if im wrong, Im sure MoveObject() has angle parameters
|
Originally Posted by Giacomand
You could do something like this:
pawn Code:
|
Originally Posted by yugokoral
And how can i stop the timer, when the object is in right position?
|
forward rotation(); // The call back Timer.
new rottimer; //Timer
public OnGameModeInit()
{
rottimer = SetTimer("rotation", 100, 1); // The timer which will go off every millisecond.
object = CreateObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ); // The object (Fill in the spaces)
return 1;
}
public rotation() // The callback
{
new Float:rotx, Float:roty, Float:rotz; //Floats
SetObjectRot(object, 0, 0, +0.1); // Will set the Z rot +0.1 every millisecond
GetObjectRot(object, rotx, roty, rotz)// Checks the pos
if(rotz == 100.0) KillTimer(rottimer); //Checks if the z rot is 100.0 and kills the timer if it is.
return 1;
}
#include <a_samp>
new zapornice;
new rottimer;
public OnGameModeInit()
{
rottimer = SetTimer("OnPlayerCommandText", 100, 1); // The timer which will go off every millisecond.
zapornice = CreateObject(968,-1572.203613,658.795593,6.918911,0.000000,0.000000,90.000000);//zapornica odprta
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/skok", true)==0)
{
new Float:rotx, Float:roty, Float:rotz; //Floats
SetObjectRot(zapornice, 0, +0.1, 90.0); // Will set the Z rot +0.1 every millisecond
GetObjectRot(zapornice, rotx, roty, rotz)// Checks the pos
if(roty == 90.0) KillTimer(rottimer); //Checks if the z rot is 100.0 and kills the timer if it is.
return 1;
}
return 0;
}
C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\zapornice.pwn(28) : error 029: invalid expression, assumed zero C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\zapornice.pwn(28) : warning 215: expression has no effect C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\zapornice.pwn(28) : warning 215: expression has no effect C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\zapornice.pwn(28) : error 001: expected token: ";", but found ")" C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\zapornice.pwn(28) : error 029: invalid expression, assumed zero C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\zapornice.pwn(28) : fatal error 107: too many error messages on one line Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 4 Errors.
Originally Posted by yugokoral
...
|
#include <a_samp>
forward rotation();
new rottimer;
new zapornice;
new bool:rotate;
public OnGameModeInit()
{
zapornice = CreateObject(968, -1572.203613, 658.795593, 6.918911, 0.000000, 0.000000, 90.000000);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/skok", true))
{
if(rotate == true) return 1;
rottimer = SetTimer("rotation", 100, 1);
rotate = true;
return 1;
}
return 0;
}
public rotation()
{
if(rotate == false) return 1;
//
new Float:rotx, Float:roty, Float:rotz;
GetObjectRot(zapornice, rotx, roty, rotz);
SetObjectRot(zapornice, rotx, roty+0.1, rotz);
//
if(roty == 90.0)
{
KillTimer(rottimer);
rotate = false;
}
return 1;
}
#include <a_samp>
new rottimer;
new zapornice;
public OnGameModeInit()
{
zapornice = CreateObject(968, -1572.203613, 658.795593, 6.918911, 0.000000, 90.000000, 90.000000);
rottimer = SetTimer("CheckGate", 10, 1);
SetTimer("CheckGate", 10, 1);
return 1;
}
new OpenGate[MAX_PLAYERS];
forward CheckGate();
public CheckGate()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerToPoint(10.0, i, -1572.1993,663.0866,7.1875) && OpenGate[i] == 0)
{
new Float:rotx, Float:roty, Float:rotz;
GetObjectRot(zapornice, rotx, roty, rotz);
SetObjectRot(zapornice, rotx, roty-0.1, rotz);
if(roty == 0.0)
{
KillTimer(rottimer);
}
OpenGate[i] = 1;
}
else if(!PlayerToPoint(10.0, i, -1572.1993,663.0866,7.1875) && OpenGate[i] == 1)
{
OpenGate[i] = 0;
new Float:rotx, Float:roty, Float:rotz;
GetObjectRot(zapornice, rotx, roty, rotz);
SetObjectRot(zapornice, rotx, roty+0.1, rotz);
if(roty == 90.0)
{
KillTimer(rottimer);
}
}
}
}
}
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if(((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
return 0;
}
Originally Posted by yugokoral
...
|
#include <a_samp>
forward CheckGate();
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
new OpenGate[MAX_PLAYERS];
new zapornice;
public OnGameModeInit()
{
zapornice = CreateObject(968, -1572.203613, 658.795593, 6.918911, 0.000000, 90.000000, 90.000000);
SetTimer("CheckGate", 10, 1);
return 1;
}
public CheckGate()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerToPoint(10.0, i, -1572.1993,663.0866,7.1875) && OpenGate[i] == 0)
{
new Float:rotx, Float:roty, Float:rotz;
GetObjectRot(zapornice, rotx, roty, rotz);
if(roty != 0.0) SetObjectRot(zapornice, rotx, roty-0.1, rotz);
else OpenGate[i] = 1;
}
else if(!PlayerToPoint(10.0, i, -1572.1993,663.0866,7.1875) && OpenGate[i] == 1)
{
new Float:rotx, Float:roty, Float:rotz;
GetObjectRot(zapornice, rotx, roty, rotz);
if(roty != 90.0) SetObjectRot(zapornice, rotx, roty+0.1, rotz);
else OpenGate[i] = 0;
}
}
}
return 1;
}
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if(((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
return 0;
}
#include <a_samp>
forward CheckGate();
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
new zapornice;
public OnGameModeInit()
{
zapornice = CreateObject(968, -1572.203613, 658.795593, 6.918911, 0.000000, 90.000000, 90.000000);
SetTimer("CheckGate", 10, 1);
return 1;
}
public CheckGate()
{
new Float:rotx, Float:roty, Float:rotz;
GetObjectRot(zapornice, rotx, roty, rotz);
for(new i = 0; i < MAX_PLAYERS; i++) // Check if anyone is near to the gate.
{
if(IsPlayerConnected(i))
{
if(PlayerToPoint(10.0, i, -1572.1993,663.0866,7.1875))
{
if(roty != 0.0) SetObjectRot(zapornice, rotx, roty-0.1, rotz); // Someone is near to the gate, start opening
return 1;
}
}
}
if(roty != 90.0) SetObjectRot(zapornice, rotx, roty+0.1, rotz); //There was no one near to the gate, start closing
return 1;
}
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if(((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
return 0;
}
#include <a_samp>
forward CheckGate();
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
new zapornice;
public OnGameModeInit()
{
zapornice = CreateObject(968, -1572.203613, 658.795593, 6.918911, 0.000000, 90.000000, 90.000000);
SetTimer("CheckGate", 10, 1);
return 1;
}
public CheckGate()
{
new Float:rotx, Float:roty, Float:rotz;
GetObjectRot(zapornice, rotx, roty, rotz);
for(new i = 0; i < MAX_PLAYERS; i++) // Check if anyone is near to the gate.
{
if(IsPlayerConnected(i))
{
if(PlayerToPoint(10.0, i, -1572.1993,663.0866,7.1875))
{
if(roty > 0.0) SetObjectRot(zapornice, rotx, roty-0.1, rotz); // Someone is near to the gate, start opening
return 1;
}
}
}
if(roty < 90.0) SetObjectRot(zapornice, rotx, roty+0.1, rotz); //There was no one near to the gate, start closing
return 1;
}
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if(((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
return 0;
}