Author Topic: Object dissapear on a specific command  (Read 2652 times)

xxxMDjxxx

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
  • SS-division*game hosting
    • View Profile
Object dissapear on a specific command
« on: October 16, 2011, 10: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..

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Object dissapear on a specific command
« Reply #1 on: October 16, 2011, 10: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]
« Last Edit: October 20, 2011, 10:12:58 pm by Thijn »

xxxMDjxxx

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
  • SS-division*game hosting
    • View Profile
Re: Object dissapear on a specific command
« Reply #2 on: October 20, 2011, 08:36:11 pm »
hmm.. not realy working...

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Object dissapear on a specific command
« Reply #3 on: October 20, 2011, 10: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..

xxxMDjxxx

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
  • SS-division*game hosting
    • View Profile
Re: Object dissapear on a specific command
« Reply #4 on: October 22, 2011, 10: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...

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Object dissapear on a specific command
« Reply #5 on: October 22, 2011, 04:56:23 pm »
Those commands should be in the event onPlayerCommand.

xxxMDjxxx

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
  • SS-division*game hosting
    • View Profile
Re: Object dissapear on a specific command
« Reply #6 on: October 24, 2011, 01: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...

xxxMDjxxx

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
  • SS-division*game hosting
    • View Profile
Re: Object dissapear on a specific command
« Reply #7 on: October 24, 2011, 06: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?
« Last Edit: October 24, 2011, 06:10:01 pm by xxxMDjxxx »

AdTec_224

  • Developer
  • Newbie
  • *****
  • Posts: 36
  • Karma: +3/-5
    • View Profile
Re: Object dissapear on a specific command
« Reply #8 on: October 24, 2011, 06: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;
}

SugarD

  • Argonath RPG Dev/Manager
  • Tester
  • Sr. Member
  • ****
  • Posts: 820
  • Karma: +37/-75
  • STOP IN THE NAME OF THE COLESLAW!
    • View Profile
    • Clan Xperience
Re: Object dissapear on a specific command
« Reply #9 on: October 24, 2011, 10: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.

 

© Liberty Unleashed Team.