The International Simutrans Forum

Development => Scripting Scenarios and AI => Topic started by: Yona-TYT on October 28, 2016, 11:21:23 AM

Title: [regions]¿player = null or player = 9 ?.
Post by: Yona-TYT on October 28, 2016, 11:21:23 AM
error:


(https://www.dropbox.com/s/s9b0m9dv3k6bijj/senariocrashafterremovecompany.PNG?dl=1)
How to know if the player is null ?, I use player_x(pl).is_active()?

Title: Re: [regions]¿player = null or player = 9 ?.
Post by: DrSuperGood on October 28, 2016, 03:56:25 PM
Surely you could test the value?

local po = player_x(pl)
if (po) {
    // stuff that needs po to exist
}
[CODE]
Title: Re: [regions]¿player = null or player = 9 ?.
Post by: Dwachs on October 30, 2016, 07:32:11 AM
@DrSuperGood: No. This is a design flaw of the scripting api (by myself). It would need some minor changes.

@Yona: could you please always copy the relevant scripting code into your bug reports? Are you sure, you got the order of the parameters right?

Title: Re: [regions]¿player = null or player = 9 ?.
Post by: Yona-TYT on October 30, 2016, 05:06:19 PM



if ((pl-2)<num && pl!=0 && pl!=1 && pl!=14)


{


if (playersave[pl-2].plsave==null && !tile_x(coord_label1[pl-2].x, coord_label1[pl-2].y, coord_label1[pl-2].z).find_object(mo_label))


{


local c_label = {x=coord_label1[pl-2].x, y=coord_label1[pl-2].y}


label_x.create(c_label, player_x(pl), translate("Entre player number (1-12)"))


player_x(pl).book_cash(10000)


}
      }