Liberty Unleashed

Scripting => Script Help => Topic started by: xxxMDjxxx on October 16, 2011, 09:21:23 am

Title: Object dissapear on a specific command
Post by: xxxMDjxxx on October 16, 2011, 09:21:23 am
Hm, how could i make a object, lets say a fence and put it in front a driveway of a house, and make it dissapear with a command like /open and when i send /close the fence will apear again?
I would put a gate at the enterance to a mansion..
Title: Re: Object dissapear on a specific command
Post by: Thijn on October 16, 2011, 09:38:52 am
Code: [Select]
Make a global var that holds the fence:
[code]
oFence <- CreateObject( ModelID, Vector );
You can add that to onScriptLoad();

Then when you use the open command:
Code: [Select]
else if ( cmd == "open" )
{
oFence.VirtualWorld = 2;
return 1;
}
Then with the close command it will be:
Code: [Select]
else if ( cmd == "close" )
{
oFence.VirtualWorld = 0;
return 1;
}

You could add some more protection, like checking if you are really standing near the fence etc.[/code]
Title: Re: Object dissapear on a specific command
Post by: xxxMDjxxx on October 20, 2011, 07:36:11 pm
hmm.. not realy working...
Title: Re: Object dissapear on a specific command
Post by: Thijn on October 20, 2011, 09:12:35 pm
"not really working..." wtf does that support to mean?
Give us some more details! Does it give any error, what did you try to fix it.
With a reply "its not working" we can't do much..
Title: Re: Object dissapear on a specific command
Post by: xxxMDjxxx on October 22, 2011, 09:56:06 am
"not really working..." wtf does that support to mean?
Give us some more details! Does it give any error, what did you try to fix it.
With a reply "its not working" we can't do much..

Hehe, sorry...
Well the object is shown, but it doesent "dissapear"...
There are no errors in the server window.

the code is:

Code: [Select]
function onScriptLoad()
{
CreateSphere( Vector( 194.33, -1195.3, 26.16 ), 3.0, Colour( 0, 136, 255 ) )
oFence <- CreateObject( 1281, Vector( 844.1, -419.5, 14.97 ) )
return 1;
}

function onPlayerEnterSphere( player, sphere )
 if ( sphere.ID == 12 )
 {
  MessagePlayer( "Anticefur CENTER:", player, 0, 136, 255 );
  MessagePlayer( "Owner: xXxMDjxXx", player, 0, 136, 255 );
  MessagePlayer( "Odkup: NONE", player, 0, 136, 255 );
  MessagePlayer( "Najem: NONE", player, 0, 136, 255 );
  MessagePlayer( "Vsebuje: orozja, vozila, parkirna hisa, ograja", player, 0, 136, 255 );
  return 1;
 }

else if ( cmd == "accso" )
{
 oFence.VirtualWorld = 2;
 return 1;
}

else if ( cmd == "accsz" )
{
 oFence.VirtualWorld = 0;
 return 1;
}

I made a property on my server, so when someone walks over the sphere they see the text (owner, cost, cars etc...)
And to prevent my cars from being stolen i wanted to make a gate, which would be "remote controled" so only people with the code could open the gates and dive with my cars...
Title: Re: Object dissapear on a specific command
Post by: Thijn on October 22, 2011, 03:56:23 pm
Those commands should be in the event onPlayerCommand.
Title: Re: Object dissapear on a specific command
Post by: xxxMDjxxx on October 24, 2011, 12:11:46 am
try this:

Nope, now the fence doesent even isnt showing up, no sphere too... Idk. what the hell is wrong with this script, i thought it could be done... No errors in the conslole eather...
Title: Re: Object dissapear on a specific command
Post by: xxxMDjxxx on October 24, 2011, 05:07:15 pm
try this:

Code: (GeSHi) [Select]
function onScriptLoad()
{
CreateSphere( Vector( 194.33, -1195.3, 26.16 ), 3.0, Colour( 0, 136, 255 ) )
oFence <- CreateObject( 1281, Vector( 844.1, -419.5, 14.97 ) )
return 1;
}

function onPlayerEnterSphere( player, sphere )
 if ( sphere.ID == 12 )
 {
  MessagePlayer( "Anticefur CENTER:", player, 0, 136, 255 );
  MessagePlayer( "Owner: xXxMDjxXx", player, 0, 136, 255 );
  MessagePlayer( "Odkup: NONE", player, 0, 136, 255 );
  MessagePlayer( "Najem: NONE", player, 0, 136, 255 );
  MessagePlayer( "Vsebuje: orozja, vozila, parkirna hisa, ograja", player, 0, 136, 255 );
  return 1;
 }

function onPlayerCommand( player, cmd )
{
if ( cmd == "accso" )
{
 oFence.VirtualWorld = 2;
 return 1;
}

else if ( cmd == "accsz" )
{
 oFence.VirtualWorld = 0;
 return 1;
}


Actualy now i get an error ...:

Code: [Select]
COMMAND: xxxmdjxxx: accso

AN ERROR HAS OCCURED [wrong number of parameters]

CALLSTACK

LOCALS
COMMAND: xxxmdjxxx: accsz

AN ERROR HAS OCCURED [wrong number of parameters]

CALLSTACK

LOCALS


the script
Code: [Select]
function onScriptLoad()
{
CreateSphere( Vector( 194.33, -1195.3, 26.16 ), 3.0, Colour( 0, 136, 255 ) )
oFence <- CreateObject( 1289, Vector( 844.1, -419.5, 14.97 ) )
return 1;
}

function onPlayerEnterSphere( player, sphere )
 if ( sphere.ID == 12 )
 {
  MessagePlayer( "Anticefur CENTER:", player, 0, 136, 255 );
  MessagePlayer( "Owner: xXxMDjxXx", player, 0, 136, 255 );
  MessagePlayer( "Odkup: 100€", player, 0, 136, 255 );
  MessagePlayer( "Najem: 1€", player, 0, 136, 255 );
  MessagePlayer( "Vsebuje: orozja, vozila, parkirna hisa, ograja", player, 0, 136, 255 );
  return 1;
 }

function onPlayerCommand( player, cmd )
{
if ( cmd == "accso" )
{
 oFence.VirtualWorld = 2;
 return 1;
}

else if ( cmd == "accsz" )
{
 oFence.VirtualWorld = 1;
 return 1;
}}


PS. Ja sam iz SLO, lijep pozdrav D.Mandi?
Title: Re: Object dissapear on a specific command
Post by: AdTec_224 on October 24, 2011, 05:35:59 pm
Code: [Select]
function onScriptLoad()
{
CreateSphere( Vector( 194.33, -1195.3, 26.16 ), 3.0, Colour( 0, 136, 255 ) );
oFence <- CreateObject( 1289, Vector( 844.1, -419.5, 14.97 ) );

return 1;
}

function onPlayerEnterSphere( player, sphere )
{
if ( sphere.ID == 12 )
{
MessagePlayer( "Anticefur CENTER:", player, 0, 136, 255 );
MessagePlayer( "Owner: xXxMDjxXx", player, 0, 136, 255 );
MessagePlayer( "Odkup: 100€", player, 0, 136, 255 );
MessagePlayer( "Najem: 1€", player, 0, 136, 255 );
MessagePlayer( "Vsebuje: orozja, vozila, parkirna hisa, ograja", player, 0, 136, 255 );
}

return 1;
}

function onPlayerCommand( player, command, params )
{
local cmd = command.tolower();

if ( cmd == "accso" )
{
if ( oFence ) oFence.VirtualWorld = 2;
}
else if ( cmd == "accsz" )
{
  if ( oFence ) oFence.VirtualWorld = 0;
}

return 1;
}
Title: Re: Object dissapear on a specific command
Post by: SugarD on October 24, 2011, 09:44:08 pm
If you assign the object an ID # and stored it in a database, you could use the functions to remove it after via that same ID. Stormeus did that as a test on a server we are developing and it seems to work well.