1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Re-useable items

Discussion in 'Development' started by blt950, Sep 13, 2013.

  1. blt950

    blt950 HL2RP fan and Lua Scripter

    Hey, I'm creating cuffs instead of zipties, but I seem to not be able to make it re-useable. In terms of, you don't loose the item after using it.

    Any ideas how to solve this issue?

    Script:
    Code:
    --[[
    	? 2013 CloudSixteen.com do not share, re-distribute or modify
    	without permission of its author ([email protected]).
    --]]
    
    local ITEM = Clockwork.item:New();
    ITEM.name = "Cuffs";
    ITEM.cost = 100;
    ITEM.model = "models/katharsmodels/handcuffs/handcuffs-1.mdl";
    ITEM.weight = 0.2;
    ITEM.access = "v";
    ITEM.useText = "Cuff";
    ITEM.factions = {FACTION_SECURITY};
    ITEM.business = true;
    ITEM.description = "Metal cuffs where you can tie peoples hands with.";
    
    -- Called when a player uses the item.
    function ITEM:OnUse(player, itemEntity)
    	if (player.isCuffing) then
    		Clockwork.player:Notify(player, "You are already cuffing a character!");
    		
    		return false;
    	else
    		local trace = player:GetEyeTraceNoCursor();
    		local target = Clockwork.entity:GetPlayer(trace.Entity);
    		local cuffTime = Schema:GetDexterityTime(player);
    		
    		if (target) then
    			if (target:GetSharedVar("cuffed") == 0) then
    				if (target:GetShootPos():Distance( player:GetShootPos() ) <= 192) then
    					if (target:GetAimVector():DotProduct( player:GetAimVector() ) > 0 or target:IsRagdolled()) then
    						Clockwork.player:SetAction(player, "cuff", cuffTime);
    						
    						Clockwork.player:EntityConditionTimer(player, target, trace.Entity, cuffTime, 192, function()
    							if (player:Alive() and !player:IsRagdolled() and target:GetSharedVar("cuffed") == 0
    							and target:GetAimVector():DotProduct( player:GetAimVector() ) > 0) then
    								return true;
    							end;
    						end, function(success)
    							if (success) then
    								player.isCuffing = nil;
    								
    								Schema:CuffPlayer( target, true, nil);
    								
    								player:TakeItem(self);
    								player:ProgressAttribute(ATB_DEXTERITY, 15, true);
    							else
    								player.isCuffing = nil;
    							end;
    							
    							Clockwork.player:SetAction(player, "cuff", false);
    						end);
    					else
    						Clockwork.player:Notify(player, "You cannot cuff characters that are facing you!");
    						
    						return false;
    					end;
    					
    					player.isCuffing = true;
    					
    					Clockwork.player:SetMenuOpen(player, false);
    					
    					return false;
    				else
    					Clockwork.player:Notify(player, "This character is too far away!");
    					
    					return false;
    				end;
    			else
    				Clockwork.player:Notify(player, "This character is already cuffed!");
    				
    				return false;
    			end;
    		else
    			Clockwork.player:Notify(player, "That is not a valid character!");
    			
    			return false;
    		end;
    	end;
    	return false;
    end;
    
    -- Called when a player drops the item.
    function ITEM:OnDrop(player, position)
    	if (player.isCuffing) then
    		Clockwork.player:Notify(player, "You are currently cuffing a character!");
    		
    		return false;
    	end;
    end;
    
    ITEM:Register();
    
     
  2. ZeMysticalTaco

    ZeMysticalTaco yo i&#039;m a taco have some lunch Clockwork Customer

    You could make it so that after it checks that the player is tied and returns true, make it give the item.
     
  3. RJ

    RJ no pay Legend Clockwork Customer

    You'd actually want it so when you un-cuff someone, it would give the handcuff item to the person who un-cuffed the player.
     
  4. Actually, if you can get a good coder, you could probably make it so that when you tie a player with handcuffs instead of zip ties, to un-cuff them they need to have a key item (which can be checked for) than once uncuffed the player who uncuffed them recieves cuffs in their inventory.
     

Previous Readers (Total: 0)