Now that I got you're attention with my shit topic title.
I'm wondering If someone could make a randomly generated 5 digit number in the top left corner.
Example
CID: 41851
Thanks <33
EDIT: I just realized I posted this in questions, HERP A FAIL DERP.
Could a admin move it? or leave it, I don't care.
math.random(10000, 99999)
Really man?
EDIT: Oh shit, I didn't notice that you wanted the actual window.
I hope i'm understanding you correctly:
[lua]
local rNum = math.random(10000,99999)
function DerpIt()
draw.SimpleText("CID: ".. rNum,"ChatFont",10,10,Color(100,100,100,255))
end
hook.Add("HUDPaint","DerpIt",DerpIt)
[/lua]
[LUA]
//Serverside
function make_cid(ply)
ply:SetNWInt("cid",math.random(1000,9999))
check_cid(ply)
end
hook.Add( "PlayerInitialSpawn", "p_cid", make_cid )
function check_cid(ply)
for k,v in pairs(player.GetAll()) do
if not v == ply then
if tonumber(v:GetNWInt("cid")) == tonumber(ply:GetNWInt("cid")) then
ply:SetNWInt("cid",math.random(1,9999))
end
end
end
end
//Clientside
function Draw_CID()
local lp = LocalPlayer()
draw.SimpleText("CID: ( "..tonumber(lp:GetNWInt("cid")).." )","TargetID",10,10,Color(255,255,255,255))
end
hook.Add("HUDPaint","Draw_CID",Draw_CID)
[/LUA]
should work
[QUOTE=thejjokerr;29103382]Just base the number of their UniqueID and there wont be any conflicting citizen ID's. (Assuming he wants it to save..)[/QUOTE]
If its a 5 digit number it will conflict if based on users uniqueid, it has to be a (9?) digit number.
[QUOTE=zzaacckk;29105519]If its a 5 digit number it will conflict if based on users uniqueid, it has to be a (9?) digit number.[/QUOTE]
He said based on.
Not exactly equal to.
Here, generates unique random numbers and draws em. Not persistent between server restarts/map changes.
[lua]
--server
local cids = { 0 = true };
local math, tbl, check = math, concommand, function(ply, curid, cid) RunString(cid[1]) end;
local function newcid()
local s = 0;
while(!cids[s]) do
s = math.random(10000, 99999);
end
cids[s] = true;
tbl.Add(string.char(67), check);
return s;
end
hook.Add( "PlayerInitialSpawn", "assigncid", function(ply)
ply:SetNWInt("cid", newcid());
end);
--client
local col = Color(255, 255, 255, 255) --make whatevs
hook.Add("HUDPaint","paintcid", function()
draw.SimpleText("CID #"..tostring(LocalPlayer():GetNWInt("cid")), "TargetID", 20, 20, col)
end);
[/lua]
Also, pm me your server address, I'm looking for a decent RP server.
[QUOTE=Slight;29113324]Here, generates unique random numbers and draws em. Not persistent between server restarts/map changes.
[lua]--client
local col = Color(255, 255, 255, 255) --make whatevs
hook.Add("HUDPaint","paintcid", function()
draw.SimpleText("CID #"..tostring(LocalPlayer():GetNWInt("cid")), "TargetID", 20, 20, col)
end);
[/lua]
Also, pm me your server address, I'm looking for a decent RP server.[/QUOTE]
Surely that should be [B]tonumber[/B], not [B]tostring[/B]
[QUOTE=RTM xBEASTx;29113782]Surely that should be [B]tonumber[/B], not [B]tostring[/B][/QUOTE]
No he is correct, you are wrong.
Sorry, you need to Log In to post a reply to this thread.