![]() |
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:
PHP Code:
PHP Code:
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. |
I wonder how many people have stolen this half working script..
|
Quote:
Looking at NPC "trashspawner" you have multiple checks to determine the item where it's possible it will have already been determined. This could be made more efficient by either using a switch statement or storing the item names and images within an array, and then retrieving this.array[this.spawn - 1];. It also looks as if you're setting a 0.05 second timeout which shouldn't even work Serverside, where again you have a potentially unnecessary condition being checked where a conflicting condition could be true. Within "gunderak_trashdrop" you are checking a server. variable Clientside when these are only readable Serverside. It also appears as if you are communicating from Serverside to Clientside, and then back to Serverside just to increment a server. variable when this can be done at the point of dropping the NPC. Not only is this totally unnecessary and suggesting that you're not really aware of what you're doing, it will also result in a triggerserver for every single client that creates the NPC. It can also result in both the spawn and unspawn trigger being sent at the same time when (even if it was a good idea) you should only have one of these triggers occurring. Calling destroy(); Clientside will also only destroy the NPC on your client, you have no mechanism to permanently destroy the NPC and prevent it from loading on yours or other peoples clients. You yet again within "-System/Trash" you have the potential for unnecessary condition checks where params[0] == "spawn" can be checked for despite params[0] == "unspawn" already being determined as true, albeit you don't need this trigger anyway. |
Thankyou for the feedback I have taken alot of that into considoration and am going to re script it from scratch, may I ask if there would be any way to do like a triggerserver or a triggerclient on a NPC? this was one of my main problems.
|
|
You don't even need to use client-side or a timeout to spawn trash at all.
DB PHP Code:
PHP Code:
|
You make things so much simpler.
All I have to do now is add the images of random trash and presto. Would you possible know how to put names and images in an array? maybe something like. PHP Code:
But how would you read the information from that and pick a random trash object O_O PHP Code:
I was just thinking doing an array would make it look much nicer and be easier to add more items, rather than doing this. PHP Code:
|
Quote:
|
wont using int(random(0, 5)); return 0, 1, 2, 3, 4 or 5 instead of random numbers like 4.719827 and 5.827591?
I shall have to see if it returns words xD |
@Fowlplay i have made a few modifications to your system, it now works perfectly except for one slight problem. the items spawn on walls.
ive tried to put a if(onwall(this.x, this.y)){ and then destroy it but it does absolutely nothing. |
Quote:
|
Quote:
Quote:
Within the original script dontblock(); is used Clientside, so on Serverside it would still be blocking. It could always be made to do an onwall() check before dropping the NPC rather than destroying it afterwards. |
the script is serverside and an onwall check skews it up.
so I can't put it in that particular script. |
Quote:
|
if you do if onwall serverside it sais it is onwall constantly.
|
All times are GMT +2. The time now is 08:40 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.