![]() |
with(npcs[npcscount-1]) Priority ?
Ok I'm having a few problems it's a bit hard to understand / explain.
I have a spawner npc i will dumb it down as the whole code isn't needed. Here is an example.. Spawner NPC: PHP Code:
PHP Code:
PHP Code:
Any help , Ideas? |
I am very sure that Stefan uses this pattern himself a lot, so I do not see how it could not work.
|
Quote:
|
dont use function , to do that in must be serverside, instead of calling the function triggeraction to serverside and put everything in that function in serverside
PHP Code:
|
Quote:
It's not clientside it is all serverside. There is no client activity involved other than... The only flags used are (created) (playerenters) and (timeout) and vars used , playercount in the level, timeout. It isn't in a function inside the actual NPC, the script is inside of a timeout , and doesn't use any functions or triggeractions. The function above was an example rather than showing if (playerenters||timeout) {} and going through the trouble of adding timeout = ect.... because the problem was not / is not located there it is rather the fact that with(npcs[npcscount-1]){ is not working ahead of the (created) of the newly placed npc.... (everything else i said above) However I don't see how it being a function has anything to do with it ?? |
Quote:
|
Quote:
Functions are not clientside they are serversided and clientsided |
How did you think he was using putnpc2 and with() clientside?
Not only is that not possible in general, if you had read his post (key step) you would see that it's completely impossible that this script is clientside. Come on, I thought you knew how to script. |
Quote:
Edit: I would do this PHP Code:
|
Quote:
around everything else in the script , because if its created priority messes up might its playerenters also since it would be called at the same time (after created) ? [edit] I will try this l8r if no one else posts a solution, however if the problem is that it is getting the wrong npc (IE.. 2 npcs being spawned at same time) then it still wouldnt fix : ( The problem runs a bit deeper as the baddies are logged into a database and are removed after death / or on invalidity , being they are invalid when being placed they do not remove the correct string set by the placing npc. Thus the spawn npc gets stuck thinking there are more baddies than there realy is in the room and new ones dont spawn. [/edit] |
Quote:
|
Are you sure you have a string nameed thiso.type?
From what you posted, it looks like you misspelled it. |
Quote:
So im setting this.type in the new npc from the this.type of the old npc that way. Excerpt From Dach Commands.rtf: this.flag flags that only exist on server-side and belong to the npc, and are stored when the npc is a database npc thiso.flag refer to the this. flags of the executing npc when you use the with () command: with (getnpc(npc2)) setstring thiso.temp,this.temp; will copy 'this.temp' from npc2 to the current npc |
Im doing some extensive testing with the bug now that there are not many people on. Im using timevar2 and ids to show me the exact time that created is called and the exact time that int is called. So now If only one of them is called then I know for sure that its not getting the correct npc in the with()
[edit] I have found the problem. I set it to send to nc; everytime both created and call npc was called ; the id of the npc. If both were not called and only one was called it auto removed showing the this.type ect.... This is what i got after about 50 npcs lolz XD. NPC Code: What this means is that in baddy 100654 only created was called and the callnpc -1 wasn't nor the strings set. Meaning that with(npcs[npcscount-1]) was not getting the correct npc! [/edit] [edit2] Ran another test adding to a variable on each call created & callnpc and every so many baddies one screws up and with() gets the wrong npc apparently as no strings are set and the call isnt made .... [/edit2] Thus..... WTF DO I DO???? HELP? Stefan ? Eh someone ? |
I'm with Jagen. Don't use if (created) because it is created before strings are set using the with() statement. It would only work because it's run really quickly but in theory it shouldn't. The callnpcs then it needed. When I do this I do not use the if (created) I use like if (started) and callnpc -1,started type thing so it will call a new statement after it sets the variables.
Also please note that is the pattern "Stefan uses" I believe. I do not think he would be unable to code his own engine properly ;) |
Quote:
The callnpc was being called most of the time but after so many npcs it misses one or 2 randomly. 1 or 2 npcs every few minutes = alot after a few hours : ( |
Quote:
|
Global staff please stop posting BAD script!
The original script is perfectly fine, but shouldn't be bugged. The current script is not interrupted, so of course the if (created) should see all variables set. A "callnpc" is completely nonsense. The only reason for the spawn function not working would be if you call it from a bad place, e.g. "with (anothernpc) { spawn(); }" because then "setstring this.type,Undead;" would not set thiso.type. Eventually replace it with "setstring thiso.type,Undead;". Check in the script that is putting the npc if the string is actually set. |
it would be nice if gobals didnt try to bash everyone who didnt know the excat syntax for every little thing, i never bothered trying functions serverside cause i just figured that it wouldnt be , oh god sue me , hence why i asked him to post correctly , gobals are supposed to be elitests there supposed to be professional and help people, no offence to ProjectShifter cause hes the only gst i ever see going around helping people on forums and on servers, thanks for being true PS
|
Quote:
Being wrong (however spectacularly) wasn't your biggest sin here. If people are criticising you then it is mostly because:
Nobody expects you to be perfect. Nobody even expects you to be good. It is your belligerence and overconfidence that makes you a target, not your lack of skill. |
Quote:
If the string is blank in the "Spawning" npc whether it is the type or the spawnid (which is a string also set (that is missing in those few bugged npcs) with xylevelname) an error message is sent to RC. Which luckily the only one to have that problem was the one I intentionaly made to check if the error check worked. Example Taken from Baddy that errored / removed itself because it was missing its strings : [Invalid Baddy]: Name: from spawner | Debug: | Actual: 214/161 mal_dungeon5.gmap |ID:100278|Active:1 The name is the type which doesnt get set same as the debug message which is blank, the other stuff is the npcs base attributes. Its strings do not get set and it automaticaly removes itself reporting its error. with() seems to be getting an incorrect npc and setting its strings thats the only explanation that seems fit. No clue why or how. Stefan if you wish to see the spawning npc it is class : system_spawn But it isn't that much more to the npc other than a few randomish timers based on player count and some calculations for baddy spawn. ect.... |
Quote:
|
Quote:
NPC Code: I have never had problems with the npcs[npcscount-1] yet though, so it must be a special case |
Quote:
|
Quote:
|
Quote:
|
Quote:
[EDIT] O_O HOLY CHRIST THAT SCREWED EVERYTHING UP o_o . It put baddies down with no strings everytime that way O_O [/edit] |
Quote:
|
Quote:
Psssttt thats because you took out the if (npcscount>oldnpcscount) and did it XD Btw thanks I'll report any other findings XD |
Quote:
NPC Code: This way it would ensure it really adds the NPC before continuing, and if it doesn't add it, it will try to add it again. :) |
Quote:
|
Quote:
You really should think about your arguments before you use them. |
Quote:
|
Quote:
NPC Code: Did not work at first , he came on to the server and removed the if (npcscount>oldnpcscount) And then it worked ( thats when he posted "works for me" ) The real problem is that after the putnpc2 the npcscount was increasing (on very small occasions) do some local npcs loading into memory a bit farther than it should , before the with() took place, even though it was directly following the putnpc2 command. Thus the wrong npc was getting the strings set. So the new way PHP Code:
|
Quote:
|
Quote:
And thanks for trying to help If I find anything else out or the script bugs anymore I'll post again Im gone to bed l8 l8 and i have get up in 2.75 hours cooolege :asleep: |
The most important thing is that you are accessing npcscount before adding the npc, because accessing npcscount is causing the local npcs to be loaded, all local npcs in a radius of 1 level.
Most of the time the local npcs are already loaded, because several script commands have the side effect of the npcs being loaded, but in special cases it can happen that you are adding an npc into an area where there is no player and no npc activity. Before adding the npc the local npcs of the current level are loaded (radius 0), but not of the surrounding levels, may be I should change that. It might sound simple, but I must keep care to not cause a chain reaction, e.g. a local npc putting an npc, the surrounding levels are loaded, the local npcs of the surrounding levels are putting new npcs, at the end the whole gmap is loaded into memory. With putnpc2 it should not be a problem though since I don't expect local npcs to use that command when they are loaded. Ok will make putnpc2 load all surrounding levels before adding the new npc, then it should work better. |
Quote:
|
Quote:
Quote:
|
In new scripting you can just do
with (putnpc2(x,y,"script")) { ... } :) |
| All times are GMT +2. The time now is 02:03 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.