Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   parking space script (https://forums.graalonline.com/forums/showthread.php?t=86934)

[email protected] 07-16-2009 05:36 PM

parking space script
 
hi im making this parking script thing where you buy a space for the day and you can park your car there, and it doesnt allow anyone else to do so. I got a problem though, whenever I say /space 1, it is supposed to say Owner: player.account, but it doesnt. Also I think the script is supposed to be serverside, but whenever I make it serverside, anyone can go into the space and its not blockable so i gotta make it clientside. but the problem with it being clientside is that only I can see Owner:player.account;

heres the script:

PHP Code:

function onPlayerChats()
 {
if (
player.chat == "/space 1")
  {
if (
clientr.item.Money>1000)
   {
player.account=this.owner
clientr
.item.Money-=1000;
player.addMsg2("You have rented space 1 for the day!");
message Ownerplayer.account SPC!;

dontblock;
  }
else
player.addMsg2("You do not have enough money to rent a space!");
 }



fowlplay4 07-16-2009 07:39 PM

You're assigning the owner variable backwards.

this.variable = this.value;

Also you're mixing GS1 with GS2 again.. I could of sworn we went over this in another thread. Use this.chat instead of message.

this.chat = "whatever you want it to say" SPC player.account;

You can store the account in a attr[], and use that on the clientside to prevent people from walking into it or whatever you want.

Example:
PHP Code:

function onPlayerChats() {
  if (
player.chat == "setaccount") {
    
this.owner player.account;
    
this.attr[2] = this.owner;
  }
}
//#CLIENTSIDE
function onPlayerTouchsMe() {
  if (
this.attr[2] == player.accountplayer.chat "You are the owner!";


Using your properly scripted owner flag you can check if someone has rented the space or not with a check like so..

if (this.variable != null) echo("This variable has a value of" SPC this.variable @ "!");

Ronnie 07-17-2009 05:30 AM

Use a trigger client, basically the same thing as trigger server just backwards

ie.
PHP Code:

function onactionserversidecmd ) {
  switch( 
cmd ) {
  
   case 
"test":
   
triggerclient("gui",this.name,"newb");
   break;

  }
 }
 

//#CLIENTSIDE

function onactionclientsidecmd ) {
  switch( 
cmd ) {
  
   case 
"newb":
   
player.chat "Not my parking space!";
   break;

  }
 } 


DustyPorViva 07-17-2009 06:10 AM

This is probably a level NPC, so triggerclient won't work.

Angel_Light 07-17-2009 06:18 AM

Quote:

Originally Posted by DustyPorViva (Post 1507999)
This is probably a level NPC, so triggerclient won't work.

just use a triggeraction to compensate. :P

DustyPorViva 07-17-2009 06:46 AM

Quote:

Originally Posted by Angel_Light (Post 1508001)
just use a triggeraction to compensate. :P

It depends entirely on how he has it set up.

I don't even see why he needs it. onPlayertouchsme() works on serverside too... so... He could also just pass the owner through an attr if that's all he needs for comparing.


All times are GMT +2. The time now is 04:54 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.