13.09.2012, 16:58
Starting
Hello!, this is my second tutorial and im gonna show you how to make a "Moving objects"
hope i explain it in a good way , good luck
lets start
now we must use a_samp include ,it defines every function with pawno, on the very top of the script add it:
PHP код:
#include <a_samp>
PHP код:
#if defined FILTERSCRIPT
we need to call the gate something specific to not mix with another gate ids in the future, our gate will be gate1,
below
PHP код:
#if defined FILTERSCRIPT
PHP код:
new gate1;//make sure to end it with ;
for defineing it we need to add it under:
PHP код:
public OnFilterScriptInit()
PHP код:
public OnGameModeInit()
PHP код:
OnFilterScriptInit()
PHP код:
gate1 = CreateObject(objectid,x,y,z,rot:x,rot:y,rot:z);
CreateObject is obvouis to the create the object
x,z,y are a floats to set the place of the object, rot = rotation
now a realy example:
PHP код:
gate1 = CreateObject(980, 1245.5999755859, -767.09997558594, 93.900001525879, 0.0, 0.0, 0.0, 100.0);// like this
enter this function :
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/open", true)){
if(IsPlayerInRangeOfPoint(playerid, 15.0, 1245.5999755859, -767.09997558594, 93.900001525879)){
MoveObject(gate1, 1256.5999755859,-767.09997558594, 93.900001525879, 3.0, 0.0, 0.0, 0.0);
SendClientMessage(playerid, 0x0000BBAA, "the Gate Opened Successfuly , Weclome !");
return 1;
}
}
if(!strcmp(cmdtext, "/close", true)){
if(IsPlayerInRangeOfPoint(playerid, 15.0, 1245.5999755859, -767.09997558594, 93.900001525879)){
MoveObject(gate1, 1245.5999755859, -767.09997558594, 93.900001525879, 3.0, 0.0, 0.0, 0.0);
SendClientMessage(playerid, 0xAA3333AA, "the Gate Closed successfuly !");
return 1;
}
}
return 0;
}
PHP код:
if(!strcmp(cmdtext, "/open", true)){
PHP код:
if(IsPlayerInRangeOfPoint(playerid, 15.0, 1245.5999755859, -767.09997558594, 93.900001525879)){
PHP код:
MoveObject(gate1, 1245.5999755859, -767.09997558594, 93.900001525879, 3.0, 0.0, 0.0, 0.0);
PHP код:
SendClientMessage(playerid, 0x0000BBAA, "the Gate Opened Successfuly , Weclome !");
the /close Command is the same but we add the origin coords back.
in the last our code should be like this:
PHP код:
#include <a_samp>
#define FILTERSCRIPT
new gate1;
public OnFilterScriptInit()
{
Gate1 = CreateObject(980, 1245.5999755859, -767.09997558594, 93.900001525879, 0.0, 0.0, 0.0, 100.0);//gate 1
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/open", true)){
if(IsPlayerInRangeOfPoint(playerid, 15.0, 1245.5999755859, -767.09997558594, 93.900001525879)){
MoveObject(gate1, 1256.5999755859,-767.09997558594, 93.900001525879, 3.0, 0.0, 0.0, 0.0);
SendClientMessage(playerid, 0x0000BBAA, "the Gate Opened Successfuly , Weclome !");
return 1;
}
}
if(!strcmp(cmdtext, "/close", true)){
if(IsPlayerInRangeOfPoint(playerid, 15.0, 1245.5999755859, -767.09997558594, 93.900001525879)){
MoveObject(gate1, 1245.5999755859, -767.09997558594, 93.900001525879, 3.0, 0.0, 0.0, 0.0);
SendClientMessage(playerid, 0xAA3333AA, "the Gate Closed successfuly !");
return 1;
}
}
return 0;
}