12-26-2008, 07:33 AM | #21 |
Join Date: Dec 2008
Gametype: Capture the Flag Posts Rated Helpful 0 Times
|
Squeek wrote the following code for falldamage but can be easily changed for all damage. The problem is however that the server crashes the moment two people move inside the trigger. One can stand still with the other moving but the moment they both start moving the server crashes.
It still is very interesting code. And it does work up to the point where it crashes the server ;p. I hope someone can fix it. We tried a few variations to this code but never had a non crashing, working version. We replaced the code with a general nofalldamage for medic. Which is a good substitute for that specific problem in my map. But it would be useful for many maps that want spawn protection. Code:
local no_fall_collection = Collection() ----------------------------------------------------------------------------- -- Player spawn ----------------------------------------------------------------------------- function player_spawn( player_entity ) local player = CastToPlayer( player_entity ) -- remove from collection for playerx in no_fall_collection.items do playerx = CastToPlayer(playerx) if playerx:GetId() == player:GetId() then no_fall_collection:RemoveItem( player ) end end end ----------------------------------------------------------------------------- --trigger no_fall_damage ----------------------------------------------------------------------------- no_fall_damage = trigger_ff_script:new() function no_fall_damage:ontouch( touch_entity ) if IsPlayer( touch_entity ) then local player = CastToPlayer( touch_entity ) no_fall_collection:AddItem( player ) end end function no_fall_damage:onendtouch( touch_entity ) if IsPlayer( touch_entity ) then local player = CastToPlayer( touch_entity ) -- remove from collection for playerx in no_fall_collection.items do playerx = CastToPlayer(playerx) if playerx:GetId() == player:GetId() then no_fall_collection:RemoveItem( player ) end end end end ----------------------------------------------------------------------------- -- ondamage; remove fall damage ----------------------------------------------------------------------------- function player_ondamage ( player, damageinfo ) -- if no damageinfo do nothing if not damageinfo then return end -- Get Damage Force local damagetype = damageinfo:GetDamageType() ConsoleToAll( "damage type: "..damagetype.." - expected: "..Damage.kFall ) if damagetype == Damage.kFall then for playerx in no_fall_collection.items do playerx = CastToPlayer(playerx) if playerx:GetId() == player:GetId() then damageinfo:SetDamage(0) end end end end |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|