Goal is to make the conditions of purchase of weapons by name. That is, if the weapon Colt 1911, the price of it buy 250.
I'm doing a zone and assign money.lua script in which global values are assigned and displayed the data you need:
function money_main(e)
Prompt("Money: " .. currentmoney)
PlayerDistance = GetPlayerDistance(e);
if g_Entity[e]['plrinzone'] == 1 then
inzone = 1
if g_InKey == "+" then
currentmoney = currentmoney + 100
end
else
inzone = 0
end
end
Variables in global scripts written as:
currentmoney = 0;
inzone = 0;
In the weapons script.lua I changed the conditions in some places, because I need to do a background check on the name of the weapon and then compare price. But if the weapon is called a Shotgun, then demand the presence in the area and not worth the money, because that's the weapon you only need to look. For all other weapons need to verify the finding in the area of purchase and the name.
if Result < 20.0 and weapon_therecanbeonlyone==e then
if g_PlayerGunCount < 9 then
if g_PlayerGunID > 0 then
if g_PlayerController==0 then
if weapon_name[e] == "Shotgun" then
Prompt ("Press E to pick up the " .. weapon_name[e] .. " or T to replace" )
else
if inzone == 1 then
if weapon_name[e] == "Colt 1911" then
if currentmoney >= 250 then
Prompt ("Press E to buy the " .. weapon_name[e])
if g_KeyPressE == 1 then
PromptDuration("Collected the " .. weapon_name[e],3000)
PlaySound(e,0)
AddPlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
currentmoney = currentmoney - 250
end
end
end
end
end
else
Prompt ("Press Y Button to pick up the " .. weapon_name[e] )
end
else
if g_PlayerController==0 then
Prompt ("Press E To pick up the " .. weapon_name[e] )
else
Prompt ("Press Y Button to pick up the " .. weapon_name[e] )
end
end
else
if g_PlayerController==0 then
if g_PlayerGunID > 0 then
Prompt ("Press T to replace with " .. weapon_name[e] )
else
Prompt ("Cannot collect any more weapons" )
end
else
Prompt ("Cannot collect any more weapons" )
end
end
if g_InKey == "t" and g_PlayerGunID > 0 then
PromptDuration("Replaced with " .. weapon_name[e],3000)
PlaySound(e,0)
ReplacePlayerWeapon(e)
Destroy(e)
ActivateIfUsed(e)
weapon_therecanbeonlyone = -1
end
end
As you can see I changed the order of conditions, to make a purchase for each separately, but why not working? Debug(Prompt) showed that conditions generally are not performed.... What the problem is? Maybe he saw something wrong.
Create a game - it's like to start a new universe where there is only you and solitude with the environment