MOVE object problem... -
knackworst - 23.10.2010
I don't know how to make moving objects... i get this warning:
432.
pawn Код:
if(strcmp(cmd,"/openagate1", true)==0) {
MoveObject(971, 2897.9375, -2051.705078125, 5.4179458618164, 1);
return 1;
}
CreateObject(971, 2897.9375, -2051.705078125, 5.4179458618164, 0, 0, 268.24768066406);
if(strcmp(cmd, "/closeagate1", true)==0) {
MoveObject(971, 2897.9375, -2051.705078125, 5.4179458618164,1);
return 1;
}
warning: C:\Users\William\Downloads\Ti+Stuntacular\gamemode s\Tropical_Island.pwn(432) : warning 225: unreachable code
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
every tutorial on moving objects sux as hell!
Re: MOVE object problem... -
Mike_Peterson - 23.10.2010
This is above line 432.. and not all tutorials suck.. and are you dutch or german?
anyway.. show us the lines above line 432..
and i could help you on PM if you want..
Re: MOVE object problem... -
Badger(new) - 23.10.2010
pawn Код:
if(strcmp(cmd,"/openagate1", true)==0) {
MoveObject(971, 2897.9375, -2051.705078125, 5.4179458618164, 1);
return 1;
}
CreateObject(971, 2897.9375, -2051.705078125, 5.4179458618164, 0, 0, 268.24768066406);
if(strcmp(cmd, "/closeagate1", true)==0) {
MoveObject(971, 2897.9375, -2051.705078125, 5.4179458618164,1);
return 1;
}
You're doing it wrong.
Put all your
CreateObjects under
NOT, under
OnPlayerCommandText.
At the top of your script, below the
includes, put:
pawn Код:
new gate[replace me with how many gates you have];
Then infront of your objects which are your gates, put:
pawn Код:
gate[0]=CreateObject(blahblahblah);
So it will look like this:
pawn Код:
public OnGameModeInit(){
gate[0]=CreateObject(blahblahblah);//Start on gate[0], not gate[1] so you can have more IDs
gate[1]=CreateObject(blahblahblah);
gate[2]=CreateObject(blahblahblah);
//Make sure the number in gate[ ] is not the same as another object's number
// Make sure the number in new gate[ ] is the number of gates you have
return 1;
}
And to open the gates:
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]){
if(!strcmp(cmdtext,"/OpenGate1",true)){
MoveObject(gate[replace me with the gate you want to move],new x, new y, new z, speed);
return 1;
}
return 0;
}
e.g.
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]){
if(!strcmp(cmdtext,"/OpenGate1",true)){
MoveObject(gate[0],500.0,1337.13, 157.454,5);
return 1;
}
if(!strcmp(cmdtext,"/OpenGate2",true)){
MoveObject(gate[1],-412.144, 1646.454, 494.54524, 10);
return 1;
}
return 0;
}
Also, as they said, you've done something wrong above what you posted.
Re: MOVE object problem... -
Rafa - 23.10.2010
pawn Код:
#include <a_samp>
new Firasgate;
public OnFilterScriptInit()
{
Firasgate = CreateObject(4101, 3006.2673339844, -1934.9904785156, -88.822967529297, 0, 0, 93.9990234375); // change the coords what ever u want ... :)
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/opengate1", cmdtext, true) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 200.0, 3006.2673339844, -1934.9904785156, -88.822967529297)) // this is the range of point on player
{
MoveObject(Firasgate, 3006.2673339844, -1934.9904785156, -88.822967529297, 2.0); // u can change the coords of the object...
SendClientMessage(playerid, 0xFF8000FF, "You has open the gate."); // message to player who open/close gate
}else{
SendClientMessage(playerid, 0xFF0000FF, "You are not near the gate."); // he is not near the gate
}
return 1;
}
if(strcmp("/closegate1", cmdtext, true) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 100.0, 2966.7800292969, -1913.8002929688, 17.379014968872))// u can change it the coords what ever u want...
{
MoveObject(Firasgate, 2966.7800292969, -1913.8002929688, 17.379014968872, 5.0); // change the coords and that ( 5.0 ) is the speed of the object...
SendClientMessage(playerid, 0xFF8000FF, "You has close the gate."); // message
}else{
SendClientMessage(playerid, 0xFF0000FF, "You are not near the gate."); // he is not near the gate
}
return 1;
}
return 0;
}
soo good luck
Re: MOVE object problem... -
knackworst - 23.10.2010
Quote:
Originally Posted by Badger(new)
pawn Код:
if(strcmp(cmd,"/openagate1", true)==0) { MoveObject(971, 2897.9375, -2051.705078125, 5.4179458618164, 1); return 1; } CreateObject(971, 2897.9375, -2051.705078125, 5.4179458618164, 0, 0, 268.24768066406); if(strcmp(cmd, "/closeagate1", true)==0) { MoveObject(971, 2897.9375, -2051.705078125, 5.4179458618164,1); return 1; }
You're doing it wrong.
Put all your CreateObjects under
NOT, under OnPlayerCommandText.
At the top of your script, below the includes, put:
pawn Код:
new gate[replace me with how many gates you have];
Then infront of your objects which are your gates, put:
pawn Код:
gate[0]=CreateObject(blahblahblah);
So it will look like this:
pawn Код:
public OnGameModeInit(){ gate[0]=CreateObject(blahblahblah);//Start on gate[0], not gate[1] so you can have more IDs gate[1]=CreateObject(blahblahblah); gate[2]=CreateObject(blahblahblah); //Make sure the number in gate[ ] is not the same as another object's number // Make sure the number in new gate[ ] is the number of gates you have return 1; }
And to open the gates:
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]){ if(!strcmp(cmdtext,"/OpenGate1",true)){ MoveObject(gate[replace me with the gate you want to move],new x, new y, new z, speed); return 1; } return 0; }
e.g.
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[]){ if(!strcmp(cmdtext,"/OpenGate1",true)){ MoveObject(gate[0],500.0,1337.13, 157.454,5); return 1; } if(!strcmp(cmdtext,"/OpenGate2",true)){ MoveObject(gate[1],-412.144, 1646.454, 494.54524, 10); return 1; } return 0; }
Also, as they said, you've done something wrong above what you posted.
|
then I get this:
C:\Users\William\Downloads\Ti+Stuntacular\gamemode s\Tropical_Island.pwn(37) : error 009: invalid array size (negative, zero or out of bounds)
C:\Users\William\Downloads\Ti+Stuntacular\gamemode s\Tropical_Island.pwn(3

: error 021: symbol already defined: "gate"
C:\Users\William\Downloads\Ti+Stuntacular\gamemode s\Tropical_Island.pwn(40) : error 021: symbol already defined: "gate"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
3 Errors.
36. new gate[0]
37. new gate[1]
38. new gate[2]
39.
40. static iPlayerChatTime[MAX_PLAYERS];
Re: MOVE object problem... -
Badger(new) - 23.10.2010
If you don't understand my way, I'd recommend what Rafa put since he's gone and done it all for you:
Quote:
pawn Код:
#include <a_samp>
new Firasgate;
public OnFilterScriptInit() { Firasgate = CreateObject(4101, 3006.2673339844, -1934.9904785156, -88.822967529297, 0, 0, 93.9990234375); // change the coords what ever u want ... :) return 1; }
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp("/opengate1", cmdtext, true) == 0) { if(IsPlayerInRangeOfPoint(playerid, 200.0, 3006.2673339844, -1934.9904785156, -88.822967529297)) // this is the range of point on player { MoveObject(Firasgate, 3006.2673339844, -1934.9904785156, -88.822967529297, 2.0); // u can change the coords of the object... SendClientMessage(playerid, 0xFF8000FF, "You has open the gate."); // message to player who open/close gate }else{ SendClientMessage(playerid, 0xFF0000FF, "You are not near the gate."); // he is not near the gate } return 1; } if(strcmp("/closegate1", cmdtext, true) == 0) { if(IsPlayerInRangeOfPoint(playerid, 100.0, 2966.7800292969, -1913.8002929688, 17.379014968872))// u can change it the coords what ever u want... { MoveObject(Firasgate, 2966.7800292969, -1913.8002929688, 17.379014968872, 5.0); // change the coords and that ( 5.0 ) is the speed of the object... SendClientMessage(playerid, 0xFF8000FF, "You has close the gate."); // message }else{ SendClientMessage(playerid, 0xFF0000FF, "You are not near the gate."); // he is not near the gate } return 1; } return 0; }
|
Re: MOVE object problem... -
knackworst - 23.10.2010
Quote:
Originally Posted by Badger(new)
If you don't understand my way, I'd recommend what Rafa put since he's gone and done it all for you:
|
I don't want in range of, I WANT IT ONLY to be RCON cmd...
Re: MOVE object problem... -
Badger(new) - 23.10.2010
Ok...
Here's a modified version of Rafa's script:
pawn Код:
#include <a_samp>
new Firasgate;
public OnFilterScriptInit()
{
Firasgate = CreateObject(4101, 3006.2673339844, -1934.9904785156, -88.822967529297, 0, 0, 93.9990234375); // change the coords what ever u want ... :)
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/opengate1", cmdtext, true) == 0)
{
if(IsPlayerAdmin(playerid))
{
MoveObject(Firasgate, 3006.2673339844, -1934.9904785156, -88.822967529297, 2.0); // u can change the coords of the object...
SendClientMessage(playerid, 0xFF8000FF, "You has open the gate."); // message to player who open/close gate
}
return 1;
}
if(strcmp("/closegate1", cmdtext, true) == 0)
{
if(IsPlayerAdmin(playerid))
{
MoveObject(Firasgate, 2966.7800292969, -1913.8002929688, 17.379014968872, 5.0); // change the coords and that ( 5.0 ) is the speed of the object...
SendClientMessage(playerid, 0xFF8000FF, "You has close the gate."); // message
}
return 1;
}
return 0;
}
Re: MOVE object problem... -
knackworst - 24.10.2010
thanks, but now when I open gate, my closed gate is still on the same place...
Re: MOVE object problem... -
Rafa - 24.10.2010
than u have misstake in ur coords if the gate its not closing...
or u just can use timer for automatic closing xD