Mc_Trekkie Posted February 17, 2012 Share Posted February 17, 2012 Итак,Я сделал работу врачом,НО- Лечит и отнимает(Прибавляет) деньги без конца(Даже если ХП полное) Вот код: function Medic (attacker, attackerweapon, bodypart, loss) health = getElementHealth (source) local MedicTeam = createTeam ( "Medic", 200, 0, 100 ) if (attackerweapon == 41) and (loss > 1) and ( health < 100 ) and MedicTeam then setElementHealth( source, getElementHealth(source) + 10 ) takePlayerMoney (source, 10) givePlayerMoney (attacker, 10) end end addEventHandler ("onPlayerDamage", getRootElement(), Medic ) Проверку команды делать функцией: Link to comment
rafull6 Posted February 17, 2012 Share Posted February 17, 2012 попробуй function Medic (attacker, attackerweapon, bodypart, loss) health = getElementHealth (source) local MedicTeam = createTeam ( "Medic", 200, 0, 100 ) if (attackerweapon == 41) and (loss > 1) and ( health < 100 ) and MedicTeam then setElementHealth( source, getElementHealth(source) + 10 ) takePlayerMoney (source, 10) givePlayerMoney (attacker, 10) elseif (attackerweapon == 41) and (loss > 1) and ( health > 100 ) and MedicTeam then takePlayerMoney (source, 0) givePlayerMoney (attacker, 0) end end addEventHandler ("onPlayerDamage", getRootElement(), Medic ) Link to comment
Mc_Trekkie Posted February 18, 2012 Author Share Posted February 18, 2012 Наверно работает,щас проверить не могу(Играю 1 на серве) Спасибо.Выручаешь Link to comment
Mc_Trekkie Posted February 18, 2012 Author Share Posted February 18, 2012 Не работает. Link to comment
Kenix Posted February 18, 2012 Share Posted February 18, 2012 Клиент addEventHandler( 'onClientPlayerDamage',localPlayer, function( attacker, weapon, bodypart, loss ) local health = getElementHealth( source ) local team = getPlayerTeam( attacker ) if team then if attacker and attacker ~= source and weapon == 41 and getTeamName( team ) == 'Medic' and health < 100 then if getPlayerMoney( ) >= 10 then cancelEvent( ) end end end end ) Сервер createTeam ( "Medic", 200, 0, 100 ) addEventHandler( 'onPlayerDamage',root, function( attacker, weapon, bodypart, loss ) local health = getElementHealth( source ) local team = getPlayerTeam( attacker ) if team then if attacker and attacker ~= source and weapon == 41 and getTeamName( team ) == 'Medic' and health < 100 then local money = getPlayerMoney( source ) if money >= 10 then givePlayerMoney( attacker,10 ) takePlayerMoney( source,10 ) setElementHealth( source,getElementHealth( source ) + 10 ) end end end end ) Обновил. Link to comment
Mc_Trekkie Posted February 18, 2012 Author Share Posted February 18, 2012 Дебаг орёт,что плохой аргумент. а так всё понял(Свою ошибку)-Не сделал проверку на деньги Link to comment
Mc_Trekkie Posted February 19, 2012 Author Share Posted February 19, 2012 Щас буду разбираться,что у меня было не так! И дебаг опять орёт на то же Link to comment
Kenix Posted February 19, 2012 Share Posted February 19, 2012 Покажи лог. Мы не телепаты. Link to comment
Mc_Trekkie Posted February 19, 2012 Author Share Posted February 19, 2012 Окай.Ща. [2012-02-19 10:19:13] Medicscript restarted successfully [2012-02-19 10:19:45] WARNING: Medicscript\server.lua:6: Bad argument @ 'getPlayerTeam' Link to comment
Kenix Posted February 19, 2012 Share Posted February 19, 2012 Сервер createTeam ( "Medic", 200, 0, 100 ) addEventHandler( 'onPlayerDamage',root, function( attacker, weapon, bodypart, loss ) local health = getElementHealth( source ) if isElement( attacker ) and attacker ~= source and weapon == 41 and health < 100 then local team = getPlayerTeam( attacker ) if team then if getTeamName( team ) == 'Medic' then local money = getPlayerMoney( source ) if money >= 10 then givePlayerMoney( attacker,10 ) takePlayerMoney( source,10 ) setElementHealth( source,getElementHealth( source ) + 10 ) end end end end end ) Клиент addEventHandler( 'onClientPlayerDamage',localPlayer, function( attacker, weapon, bodypart, loss ) local health = getElementHealth( source ) if isElement( attacker ) and attacker ~= source and weapon == 41 and health < 100 then local team = getPlayerTeam( attacker ) if team then if getTeamName( team ) == 'Medic' then if getPlayerMoney( ) >= 10 then cancelEvent( ) end end end end end ) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now