Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random spawn players
#5
(09.02.2020, 23:05)Quarchodron Wrote: 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]);
});
Thank you very much. I suffered for several days, with this.
May Sleeper protect you))

(09.02.2020, 23:05)Quarchodron Wrote: 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]);
});
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
Reply


Messages In This Thread
Random spawn players - by demor140202 - 09.02.2020, 01:18
RE: Random spawn players - by Quarchodron - 09.02.2020, 18:00
RE: Random spawn players - by demor140202 - 09.02.2020, 19:27
RE: Random spawn players - by Quarchodron - 09.02.2020, 23:05
RE: Random spawn players - by demor140202 - 09.02.2020, 23:47
RE: Random spawn players - by Quarchodron - 10.02.2020, 07:37

Possibly Related Threads…
Thread Author Replies Views Last Post
  Give random item for Player liegav 6 6,361 14.02.2018, 18:30
Last Post: Patrix
  Random Number Osmith 5 4,587 20.02.2016, 14:21
Last Post: Blacha

Forum Jump:


Users browsing this thread: 1 Guest(s)