![]() |
Random spawn players - Printable Version +- Gothic Online Forums (https://archive.gothic-online.com) +-- Forum: Scripting (English) (https://archive.gothic-online.com/forum-11.html) +--- Forum: Scripting Help (https://archive.gothic-online.com/forum-12.html) +--- Thread: Random spawn players (/thread-2705.html) |
Random spawn players - demor140202 - 09.02.2020 Hello, Polish friends) How do I make random player spawn? For a person to spawn on one of the many recorded coordinates. p.s Thank you, you are cool RE: Random spawn players - Quarchodron - 09.02.2020 Use rand() function RE: Random spawn players - demor140202 - 09.02.2020 (09.02.2020, 18:00)Quarchodron Wrote: Use rand() function sorry, i noob, but I know about this command, I just don't understand how to connect it to coordinates... RE: Random spawn players - Quarchodron - 09.02.2020 local tab = [ [x,y,z,angle], [x,y,z,angle], [x,y,z,angle] ]; addEventHandler("onPlayerSpawn", function(pid) { local random = (rand() % tab.len())-1; setPlayerPosition(pid, tab[random][0], tab[random][1],tab[random][2]); setPlayerAngle(pid, tab[random][3]); }); RE: Random spawn players - demor140202 - 09.02.2020 (09.02.2020, 23:05)Quarchodron Wrote: local tab = [Thank you very much. I suffered for several days, with this. May Sleeper protect you)) (09.02.2020, 23:05)Quarchodron Wrote: local tab = [Hello again. Random works every other time. If it didn't work, the console shows an error: [squirrel] runtime Error: 'gamemodes/prototype/server-scripts/main.nut' (Ln: 162): the index '-1' does not exist -== Local varaiable: ==- + array: tab + integer: random (-1) + integer: pid (0) + table: this RE: Random spawn players - Quarchodron - 10.02.2020 Sorru but in arg random delete this - 1 aftee bracket. And add - 1 after. Len() |