• LUA Scripting help
    2 replies, posted
Hello I am making my own NPC shop for my gamemode and I have made this code: [CODE]function buyglock() if ply:HasWeapon( "weapon_mad_glock" )then ply:PrintMessage( HUD_PRINTTALK, " You already have this weapon. " ) else if ply:GetMoney() ==>100 then ply:Give( "weapon_mad_glock" ) elseif ply:GetMoney() =<100 then ply:PrintMessage( HUD_PRINTTALK, " You do not have enough money for this item. " ) end end end concommand.Add( "_wgrp_buyglock", buyglock) [/CODE] This is homemade code, can someone tell me what I have done wrong? The derma menu has a spawnicon that activates that console command. This is the error: [url]https://dl.dropboxusercontent.com/u/88717145/Error.PNG[/url] Thanks for any help. [editline]15th April 2013[/editline] Here is the init.lua in the entity: -- Code by WholeGamer (email [email]wholegamer@gmail.com[/email]). Do NOT redistribute without permission. function ENT:Initialize( ) --This function is run when the entity is created so it's a good place to setup our entity. self:SetModel( "models/humans/group01/female_01.mdl" ) -- Sets the model of the NPC. self:SetHullType( HULL_HUMAN ) -- Sets the hull type, used for movement calculations amongst other things. self:SetHullSizeNormal( ) self:SetNPCState( NPC_STATE_SCRIPT ) self:SetSolid( SOLID_BBOX ) -- This entity uses a solid bounding box for collisions. self:CapabilitiesAdd( CAP_ANIMATEDFACE ) -- Adds what the NPC is allowed to do ( It cannot move in this case ). self:SetUseType( SIMPLE_USE ) -- Makes the ENT.Use hook only get called once at every use. self:DropToFloor() self:SetMaxYawSpeed( 90 ) --Sets the angle by which an NPC can rotate at once. end function ENT:AcceptInput( Name, Activator, Caller ) if Name == "Use" and Caller:IsPlayer() then umsg.Start("ShopNPCUsed", Caller) -- Prepare the usermessage to that same player to open the menu on his side. umsg.End() -- We don't need any content in the usermessage so we're sending it empty now. end end function buyglock() if ply:HasWeapon( "weapon_mad_glock" )then ply:PrintMessage( HUD_PRINTTALK, " You already have this weapon. " ) else if ply:GetMoney() ==>100 then ply:Give( "weapon_mad_glock" ) elseif ply:GetMoney() =<100 then ply:PrintMessage( HUD_PRINTTALK, " You do not have enough money for this item. " ) end end end concommand.Add( "_wgrp_buyglock", buyglock)
You should use [lua] tags around your code, and there's no indication of what line 32 is. But, just by glancing over it, I see this: if ply:GetMoney() ==>100 then which should be: if ply:GetMoney() >= 100 then and the other operator should not be =< but <=
This is line 32: if ply:GetMoney() ==>100 then [editline]15th April 2013[/editline] Can anyone help? [editline]15th April 2013[/editline] Scratch that Thankyou for the help
Sorry, you need to Log In to post a reply to this thread.