Page 2 of 2

Re: Scripting lua trying get WHILE

Posted: Thu Jun 24, 2010 12:54 am
by Maveritchell
Deviss wrote:i know and i tested by make crash :S , maybe because WHILE? but supposly while must work without problems in lua, but always i use it cause crash :S , for this reason i need if zerted can save me, or yes or yes i need use IF for no crash xD
I told you why the while loops are probably crashing - you need to be using them only to iterate through something, for example:

Code: Select all

variable = 0
while variable < 10 do
	print(variable) 
	variable + 1
end
Like Zerted said, there's no really good way to check when a character exits a vehicle. The code he's talking about would look like this (this is just the back half of the code to check when the player exits a vehicle):

Code: Select all

checkvehtime = CreateTimer("checkveh")
SetTimerValue(checkvehtime, 1)
StartTimer(checkvehtime)
checkvehicle = OnTimerElapse(
	function(timer)
		if IsCharacterHuman(GetTeamMember(1,0) or IsCharacterHuman(GetTeamMember(2,0) then
			if GetCharacterVehicle(GetTeamMember(1,0)) or GetCharacterVehicle(GetTeamMember(2,0)) then
				SetProperty("vehiclespawnname", "AddHealth", 0)
			end
		end
		SetTimerValue(checkvehtime, 1)
		StartTimer(checkvehtime)
	end,
checkvehtime
)

Re: Scripting lua trying get WHILE

Posted: Thu Jun 24, 2010 9:01 am
by Deviss
Maveritchell wrote:
Deviss wrote:i know and i tested by make crash :S , maybe because WHILE? but supposly while must work without problems in lua, but always i use it cause crash :S , for this reason i need if zerted can save me, or yes or yes i need use IF for no crash xD
I told you why the while loops are probably crashing - you need to be using them only to iterate through something, for example:

Code: Select all

variable = 0
while variable < 10 do
	print(variable) 
	variable + 1
end
Like Zerted said, there's no really good way to check when a character exits a vehicle. The code he's talking about would look like this (this is just the back half of the code to check when the player exits a vehicle):

Code: Select all

checkvehtime = CreateTimer("checkveh")
SetTimerValue(checkvehtime, 1)
StartTimer(checkvehtime)
checkvehicle = OnTimerElapse(
	function(timer)
		if IsCharacterHuman(GetTeamMember(1,0) or IsCharacterHuman(GetTeamMember(2,0) then
			if GetCharacterVehicle(GetTeamMember(1,0)) or GetCharacterVehicle(GetTeamMember(2,0)) then
				SetProperty("vehiclespawnname", "AddHealth", 0)
			end
		end
		SetTimerValue(checkvehtime, 1)
		StartTimer(checkvehtime)
	end,
checkvehtime
)
now i understand sorry i am a bit slow xD, so creating a timer but is unexact i had the idea because when you use pilot in space you gain regen of vehicle and when you exit of it, vehicle dont keep regen, but well is other hardcode more in my list :P, many thanks by your effort and time :D and for teach me again :)

Re: Scripting lua trying get WHILE

Posted: Thu Jun 24, 2010 12:29 pm
by myers73
wont setting the unit type to pilot and adding the lines in the pilot odf about vehicle regen do exactly what you are trying to do?

Re: Scripting lua trying get WHILE

Posted: Thu Jun 24, 2010 2:24 pm
by Deviss
myers73 wrote:wont setting the unit type to pilot and adding the lines in the pilot odf about vehicle regen do exactly what you are trying to do?
i didnt try xD and i dont know how lol, but yeah something a bit simil i didnt know had regen because unittype pilot so is harder code yet xD