Forum

> > CS2D > Scripts > random id
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch random id

2 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt random id

sadswsww
User Off Offline

Zitieren
I'm having problem with LUA script.
I planned to write a Lua: only 1 random player will be equipped Ak-74 when A ROUND STARTS ONLY (in zombie mode) and if that player became a zombie, he wont get Ak-74. :D.

This is my LUA. You can check and fix for me
Spoiler >


Plz help me.
Thanks a lot

Admin/Mod Kommentar

You don't have to create 2 same thread in a different name, please don't create multiple threads next time. I removed the other one. /Zeroarcanus

alt Re: random id

Rainoth
Moderator Off Offline

Zitieren
1
math.random(1,5)
Would be correct if you want to get a number between 1 and 5, but you also have to check if player exists with that id. I'd advise to use cs2d lua cmd player table and get a random value from "tableliving".

alt Re: random id

Starkkz
Moderator Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
addhook("startround","onStart")
function onStart()
local Players = player(0, "tableliving")
local TableIndex = math.random(1, #Players)
local ID = Players[TableIndex]
if ID and player(ID, "exists") then
parse("equip "..ID.." 30")
end
end
Should be shorter. Sorry about the tabs, I was on mobile phone.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht