I need Lua help!
Yes!
OK so I need image that will turn around the player and grow bigger and smaller around him if he has cool[id]==true and if not it will disappear!
If you know how plz help me I don't know images how script them plz OK thxy!
Scripts
Image turning around player and changing size
Image turning around player and changing size
img = {} -- your image
if cool[id] then	
	img[id] = image( ) -- change settings here
	tween_rotateconstantly(img[id],1)
else
	freeimage(img[id])
	img[id] = nil
end
img = {"gfx/cs2d.bmp"}
image
Mami Tomoe has written
img= {"gfx/cs2d.bmp"}
image(img,0,0,0)
LUA ERROR: sys/lua/sp-rp-script/main.lua:376: bad argument #1 to 'freeimage' (number expected, got string)
Rainoth gave to ya?
"path"
x
y
mode
[pl] (optional)img=image("gfx/instruments/d**do.png",player(id,"x"),player(id,"y"),200+id,id)
rp_wanted_img = {"gfx/cs2d.bmp"} if rp_ct[id] and player(id,"health")>0 then 				rp_wanted_img[id] = image(rp_wanted_img,player(id,"x"),player(id,"y"),200+id,id) 				tween_rotateconstantly(rp_wanted_img[id],1) 			else 				freeimage(rp_wanted_img[id]) 				rp_wanted_img[id] = nil 			end
LUA ERROR: sys/lua/sp-rp-script/main.lua:377: bad argument #1 to 'freeimage' (number expected, got string) -> [C]: in function 'freeimage' -> sys/lua/sp-rp-script/main.lua:377: in function <sys/lua/sp-rp-script/main.lua:364>
Mami Tomoe: Give it up
.
https://www.lua.org/pil/1.html PLAYER={}
rp_wanted_img=gfx/cs2d.bmp
addhook("join","_join")
function _join(id)
PLAYER[id]={}
end
rp_wanted_imgor
rp_wanted_img.."
PLAYER[id].img = image(rp_wanted_img,player(id,"x"),player(id,"y"),200+id,id)
if PLAYER[id].img then --code else --another code end
tween_rotateconstantly(PLAYERS[id].img,1) freeimage(PLAYER[id].img) PLAYER[id].img=nil
where do I put what
imgs = {}
img = "gfx/example.bmp" -- Path of rotating image
turning_spd = 5, -- Rotation speed
addhook("join","_join")
function _join(id)
	imgs[id] = nil
end
function turning_image(id)
	if cool[id] == true then
		if imgs[id] == nil then
			imgs[id] = image(img,0,0,id+200)
			tween_rotateconstantly(imgs[id],turning_spd)
		end
	else
		if imgs[id] then
			freeimage(imgs[id])
			imgs[id] = nil
		end
	end
end
addhook("ms100","_ms100")
function _ms100()
	for _, i in pairs(player(0,"table")) do
		if player(i,"health") > 0 then
			turning_image(i)
		end
	end
end
Mami Tomoe: I'll give you a step by step guide on how to use cs2d.com.
image
Masea: You don't free the image on join. You're also constantly calling multiple commands, loops and IFs for something you only need to do once.
Rainoth has written
Masea: That's what I'm saying. Why do you need to nil the parameter if you don't free the image before it?
Rainoth has written
Masea: That's what I'm saying. Why do you need to nil the parameter if you don't free the image before it?
Rainoth has written
Masea: Ye but wouldn't you normally use freeimage() too? Unless it automatically does it whenever you leave, which I doubt.
Rainoth has writtenif cool[id] then img[id] = image( ) -- change settings here tween_rotateconstantly(img[id],1) else freeimage(img[id]) img[id] = nil end
if cool[id] == true then if imgs[id] == nil then imgs[id] = image(img,0,0,id+200) tween_rotateconstantly(imgs[id],turning_spd) end else if imgs[id] then freeimage(imgs[id]) imgs[id] = nil end end
Masea has written
leave hook and freeimage + obliterate the ID of that image.
die,
endround and
join so nothing weird happens with the management of images. Yeah, it's miserable how CS2D manages these images in a poor way so we have to do these actions manually.