Spawning items, and bases

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Hey, could you explain me why World.Spawn is not working in my function? Just explain why and what, I need to understand it, not just have working, so next time I'll manage this situation without help.

This is working:
Code:
def On_PlayerSpawned(self, Player, location):
     World.Spawn("WorldFlare_New", flare_1_x, flare_1_y, flare_1_z)
This is not:
Code:
def FlareCallback(self):
    Plugin.KillTimer("Flare")
    World.Spawn("WorldFlare_New", flare_1_x, flare_1_y, flare_1_z)
It's of course Object error, like always.
def On_PlayerSpawned(self, Player, location):
World.Spawn("WorldFlare_New", flare_1_x, flare_1_y, flare_1_z)

def FlareCallback(self):
Plugin.KillTimer("Flare")
World.Spawn("WorldFlare_New", flare_1_x, flare_1_y, flare_1_z)

Are those variables (flare_1_x) declared?
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Of course. In function, full:

Code:
def On_PluginInit(self):
        Plugin.CreateTimer("Flare", 6000).Start()
       
    def FlareCallback(self):
        Plugin.KillTimer("Flare")
        '''
            Museum Outside Flares
        '''
        flare_1_x = 6026
        flare_1_y = 398
        flare_1_z = -3223
        flare_2_x = 6012
        flare_2_y = 400
        flare_2_z = -3206
        flare_3_x = 6033
        flare_3_y = 446
        flare_3_z = -3216
       
        Server.Broadcast("Petla")
        World.Spawn("WorldFlare_New", flare_1_x, flare_1_y, flare_1_z)
        World.Spawn("WorldFlare_New", flare_2_x, flare_2_y, flare_2_z)
        World.Spawn("WorldFlare_New", flare_3_x, flare_3_y, flare_3_z)
        Plugin.CreateTimer("Flare", 6000).Start()
   
    def On_PlayerSpawned(self, Player, location):
        '''
        Museum Inside Loot
        '''
        loot_1_x = 6032
        loot_1_y = 400
        loot_1_z = -3195
        World.Spawn("MedicalLootBox", loot_1_x, loot_1_y, loot_1_z)
And what is crazy when I set it in On_PlayerSpawned it's working. When in Callback it's error.
 

Snake

Moderator
Moderator
Jul 13, 2014
288
174
28
Of course. In function, full:

Code:
def On_PluginInit(self):
        Plugin.CreateTimer("Flare", 6000).Start()
      
    def FlareCallback(self):
        Plugin.KillTimer("Flare")
        '''
            Museum Outside Flares
        '''
        flare_1_x = 6026
        flare_1_y = 398
        flare_1_z = -3223
        flare_2_x = 6012
        flare_2_y = 400
        flare_2_z = -3206
        flare_3_x = 6033
        flare_3_y = 446
        flare_3_z = -3216
      
        Server.Broadcast("Petla")
        World.Spawn("WorldFlare_New", flare_1_x, flare_1_y, flare_1_z)
        World.Spawn("WorldFlare_New", flare_2_x, flare_2_y, flare_2_z)
        World.Spawn("WorldFlare_New", flare_3_x, flare_3_y, flare_3_z)
        Plugin.CreateTimer("Flare", 6000).Start()
  
    def On_PlayerSpawned(self, Player, location):
        '''
        Museum Inside Loot
        '''
        loot_1_x = 6032
        loot_1_y = 400
        loot_1_z = -3195
        World.Spawn("MedicalLootBox", loot_1_x, loot_1_y, loot_1_z)
And what is crazy when I set it in On_PlayerSpawned it's working. When in Callback it's error.
I'm not sure but try using .Stop() on the timer instead of killing it.
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
Of course. In function, full:

Code:
def On_PluginInit(self):
        Plugin.CreateTimer("Flare", 6000).Start()
     
    def FlareCallback(self):
        Plugin.KillTimer("Flare")
        '''
            Museum Outside Flares
        '''
        flare_1_x = 6026
        flare_1_y = 398
        flare_1_z = -3223
        flare_2_x = 6012
        flare_2_y = 400
        flare_2_z = -3206
        flare_3_x = 6033
        flare_3_y = 446
        flare_3_z = -3216
     
        Server.Broadcast("Petla")
        World.Spawn("WorldFlare_New", flare_1_x, flare_1_y, flare_1_z)
        World.Spawn("WorldFlare_New", flare_2_x, flare_2_y, flare_2_z)
        World.Spawn("WorldFlare_New", flare_3_x, flare_3_y, flare_3_z)
        Plugin.CreateTimer("Flare", 6000).Start()
 
    def On_PlayerSpawned(self, Player, location):
        '''
        Museum Inside Loot
        '''
        loot_1_x = 6032
        loot_1_y = 400
        loot_1_z = -3195
        World.Spawn("MedicalLootBox", loot_1_x, loot_1_y, loot_1_z)
And what is crazy when I set it in On_PlayerSpawned it's working. When in Callback it's error.
The callback method runs right?

Try putting float()

float(loot_1_x)
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Yes, Callback is working... When without World.Spawn. I just made another plugin and it's working. But here is World.Spawn.

Float didn't change anything.
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
You know Util is working on windows. But it didn't help. Still same error. I would say that I need to append World like with Player, but no. This code:

Code:
Server.Broadcast("Petla")
        World.Time = World.Time+1
        Plugin.CreateTimer("Flare", 6000).Start()
Is working like expected. So it's just problem with World.Spawn
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
Check your output.log to see if any hidden errors appeared.
Root/Rust_Server_data/Output.log
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Nope, there is only this, same error.
Code:
Traceback (most recent call last):

  File "<string>", line 62, in FlareCallback

SystemError: Object reference not set to an instance of an object
Only one thing that I learned from it is that I don't need to open game to check if it's repaired.
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Code:
World.Spawn("WorldFlare_New", flare_1_x, flare_1_y, flare_1_z)
I sum it up to remind everybody:
- Tried clean coords (without variables)
- I tried float()
- Tried CreateVector()
- It's not working only on Callback function.
- Other World objects are working, like World.Time

If other my errors are probably because of linux - this is not working on windows too. I made my plugins on windows server first, then upload. So it needs to be some problem with Fougerite.

Update:
This is working:
Append Player object to Callback function. But I don't need to spawn at player.
Code:
for player in playerobj:
            World.SpawnAtPlayer("WorldFlare_New", player)
Update:
Tried even set "rep" for Spawn, and not working

Update:
Tried Vector to be sure. Not working.
Code:
loc = Util.CreateVector(float(flare_1_x), float(flare_1_y), float(flare_1_z))
World.Spawn("WorldFlare_New", loc)
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
And again Update:

I tried to make it just like SpawnAtPlayer have:

Code:
public object SpawnAtPlayer(string prefab, Fougerite.Player p)
{
return this.Spawn(prefab, p.Location, p.PlayerClient.transform.rotation, 1);
}
Code:
loc = Util.CreateVector(float(flare_1_x), float(flare_1_y), float(flare_1_z))
World.Spawn("WorldFlare_New", loc, Quaternion.identity, 1)
But error is:
TypeError: expected Single, got Vector3

But this function is private.
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
And again Update:

I tried to make it just like SpawnAtPlayer have:

Code:
public object SpawnAtPlayer(string prefab, Fougerite.Player p)
{
return this.Spawn(prefab, p.Location, p.PlayerClient.transform.rotation, 1);
}
Code:
loc = Util.CreateVector(float(flare_1_x), float(flare_1_y), float(flare_1_z))
World.Spawn("WorldFlare_New", loc, Quaternion.identity, 1)
But error is:
TypeError: expected Single, got Vector3

But this function is private.
Try:
Python:
import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite


class Test:
    def On_Command(self, Player, cmd, args):
        if cmd == "spawn":
            if Player.Admin:
                World.Spawn("WorldFlare_New", Player.X, Player.Y +2, Player.Z)
            else:
                Player.Message("You are not allowed to use that command")
See if spawning it this way works then we know if its World.Spawn or the location you're trying to spawn it in at.
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
Yes it's working, like I said. It's not working only in Callback function. ONLY. Hooks are working fine.
 

MasterPeace

Retired Staff
Retired Staff
Feb 2, 2015
269
69
28
45
Poland
It's really nothing unusual: http://pastebin.com/mNBfnZMq

Additional libs are just because to debug, without them it's not working either.
FlareCallback is working if without World.Spawn function.
Medical Loot Box from "PlayerSpawned" is spawning.
My variables and coords are fine, working if not in FlareCallback. There is really nothing to do. There is just error.
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
It's really nothing unusual: http://pastebin.com/mNBfnZMq

Additional libs are just because to debug, without them it's not working either.
FlareCallback is working if without World.Spawn function.
Medical Loot Box from "PlayerSpawned" is spawning.
My variables and coords are fine, working if not in FlareCallback. There is really nothing to do. There is just error.
Can u try this? im not home

Sent from my Samsung Galaxy S4
Callback works (Spawns 3 flares every second), Medical box spawns on player spawn.
butttt after the callback had looped about 10 times the server crashed..
Got this from Output_log.txt
Code:
PhysicsSDK: NpScene::createActor: WriteLock is still acquired. Procedure call skipped to avoid a deadlock!
(Filename: ..\..\Physics\src\NpScene.cpp Line: 879)
Crash in winutils::ProcessInternalCrash(PEXCEPTION_POINTERS pExInfo)C
EDIT: Do you have the latest IronPythonModule found here: http://fougerite.com/resources/ironpython-module.96/
I know I had problems with the Callbacks when creating the Voting for servers time plugin