Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-17-2011, 11:42 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Trash Spawning Script Problem

What I am trying to accomplish is a script that spawns trash across the gmap and then the trash is pickupable but my script(s) seem to have an issue.
They seem to be spawning WAY more than its supposed to.
Anyway here are the scripts.

The npc trashspawner
PHP Code:
function onCreated() {
  
this.spawntime 0.05;
  
onTimeout();
}

function 
onTimeout() {
  if (
server.trashspawned 10) {
    
server.trashspawned 10;
  }
  if (
server.trashspawned 10) {
    
onSpawning();
  }
  
settimer(this.spawntime);
}

function 
onSpawning() {
  
this.spawn int(random(16));
  if (
this.spawn == "1") {
    
this.item "Tire";
    
this.itemimage "bc_trash-tire.png";
  }
  if (
this.spawn == "2") {
    
this.item "Bottle";
    
this.itemimage "bc_trash-bottle.png";
  }
  if (
this.spawn == "3") {
    
this.item "Paper";
    
this.itemimage "bc_trash-paper.png";
  }
  if (
this.spawn == "4") {
    
this.item "Motherboard";
    
this.itemimage "bc_trash-motherboard.png";
  }
  if (
this.spawn == "5") {
    
this.item "Soda";
    
this.itemimage "bc_trash-sodacan.png";
  }
  if (
this.spawn == "6") {
    
this.item "Wires";
    
this.itemimage "bc_trash-wires.png";
  }
  if (
server.trashspawned 10) {
    
temp.spawnx random(0448);
    
temp.spawny random(0448);
    
temp.putnpc2(temp.spawnxtemp.spawnynull);
    
temp.t.itemimage this.itemimage;
    
temp.t.itemname this.item;
    
temp.t.join("gunderak_trashdrop");
  }

The class gunderak_trashdrop
PHP Code:
function onCreated() {
  if (
server.trashspawned 10) {
    
destroy();
  }
  
setshape(13232);
  
setimg(this.itemimage);
}

function 
onActionGrab() {
  
client.trash += 1;
  
server.trashspawned -= 1;
  
triggerclient("gui""-System/Message""msg""Server""You gained [" this.itemname "]! You now have: " client.trash " Trash!""orange");
  
destroy();
}

//#CLIENTSIDE
function onCreated() {
  if (
server.trashspawned 10) {
    
destroy();
  }
  
triggerserver("weapon""-System/Trash""spawn");
  
dontblock();
  
drawunderplayer();
  
setshape(13232);
  if (
onwall(this.xthis.y)) {
    
destroy();
    
triggerserver("weapon""-System/Trash""unspawn");
  }

The weapon -System/Trash
PHP Code:

function onActionServerSide() {
  if (
params[0] == "unspawn") {
    if (
server.trashspawned 0) {
      
server.trashspawned--;
    }
  }
  if (
params[0] == "spawn") {
    if (
server.trashspawned 10) {
      
server.trashspawned++;
    }
  }

Any help is appriciated
PS: yes I know im probably doing this completely wrong, I cannot think of any other way to accomplish my goal.
If you would like put in an easier way your more than welcome.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:12 PM.


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