• Help me with my swep
    6 replies, posted
So i am trying to make this swep print messages in the center of the players screen but it keeps appearing on other players screen and not the person who used it. its also doing the same thing with PRINTTEXT, Also the Player:Kill Keeps killing other players other than the player holding it. I'm trying to make this addon work on a darkrp server. [code]-- My BOI Punk --Main Stuff SWEP.Category = "DJ Kitty" SWEP.Base = "weapon_base" SWEP.PrintName = "Triggerd SWEP" SWEP.Author = "DJ Kitty" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.Purpose = "Hugh Mungus WOT!?" SWEP.Instructions = "Is that sexual harassment!?!" SWEP.ViewModelFlip = false SWEP.DrawCrosshair = false SWEP.Secondary = false --Swep Models / View SWEP.ViewModel = "models/weapons/v_hands.mdl" SWEP.WorldModel = "" SWEP.ViewModelFOV = 65 SWEP.ShowViewModel = true SWEP.ShowWorldModel = true SWEP.ViewModelBoneMods = {} --Primary Settings SWEP.Primary.ClipSize = 0 SWEP.Primary.Automatic = false SWEP.Primary.DefaultClip = 0 SWEP.Primary.Ammo = "none" SWEP.DrawCrosshair = false SWEP.Primary.Delay = 10 -- Hold Type function SWEP:Initialize() self:SetWeaponHoldType("normal") end -- Primary function SWEP:PrimaryAttack() self:EmitSound("wot.mp3") if ( SERVER ) then Entity(1):PrintMessage(HUD_PRINTCENTER, "Slightly TRIGGERD") end end -- Secondary function SWEP:SecondaryAttack() self:EmitSound("harassment.mp3") if ( SERVER ) then Entity(1):PrintMessage(HUD_PRINTCENTER, "TRIGGERD") end end -- Reload function SWEP:Reload() if ( SERVER ) then Entity(1):PrintMessage(HUD_PRINTTALK, "WOT!?!") end if ( SERVER ) then Player(1):Kill() end end -- Deploy function SWEP:Deploy() end[/code]
You shouldn't use Entity(1) or Player(1) to index the swep owner. Those will return entities with the id of 1. You should use self.Owner or self:GetOwner().
[QUOTE=crazyscouter;52534609]You shouldn't use Entity(1) or Player(1) to index the swep owner. Those will return entities with the id of 1. You should use self.Owner or self:GetOwner().[/QUOTE] could you like give me an example cuz im sorta confused
Did you code this or are you even trying to do it by yourself? Don't use Entity(1), use self.Owner
[QUOTE=gonzalolog;52534625]Did you code this or are you even trying to do it by yourself? Don't use Entity(1), use self.Owner[/QUOTE] My self ;-;, I'm very new sorry.
Okay, you are doing entity (1), that won't work multiplayer, do self.Owner:PrintMessage
[QUOTE=gonzalolog;52534629]Okay, you are doing entity (1), that won't work multiplayer, do self.Owner:PrintMessage[/QUOTE] Okay i redid it should all of this work? [code]-- My BOI Punk --Main Stuff SWEP.Category = "DJ Kitty" SWEP.Base = "weapon_base" SWEP.PrintName = "Triggerd SWEP" SWEP.Author = "DJ Kitty" SWEP.Spawnable = true SWEP.AdminSpawnable = true SWEP.Purpose = "Hugh Mungus WOT!?" SWEP.Instructions = "Is that sexual harassment!?!" SWEP.ViewModelFlip = false SWEP.DrawCrosshair = false SWEP.Secondary = false --Swep Models / View SWEP.ViewModel = "models/weapons/v_hands.mdl" SWEP.WorldModel = "" SWEP.ViewModelFOV = 65 SWEP.ShowViewModel = true SWEP.ShowWorldModel = true SWEP.ViewModelBoneMods = {} --Primary Settings SWEP.Primary.ClipSize = 0 SWEP.Primary.Automatic = false SWEP.Primary.DefaultClip = 0 SWEP.Primary.Ammo = "none" SWEP.DrawCrosshair = false SWEP.Primary.Delay = 10 -- Hold Type function SWEP:Initialize() self:SetWeaponHoldType("normal") end -- Primary function SWEP:PrimaryAttack() self:EmitSound("wot.mp3") if ( SERVER ) then self.Owner:PrintMessage(HUD_PRINTCENTER, "Slightly TRIGGERD") end end -- Secondary function SWEP:SecondaryAttack() self:EmitSound("harassment.mp3") if ( SERVER ) then self.Owner:PrintMessage(HUD_PRINTCENTER, "TRIGGERD") end end -- Reload function SWEP:Reload() if ( SERVER ) then self.Owner:PrintMessage(HUD_PRINTTALK, "WOT!?!") end if ( SERVER ) then self.Owner:Kill() end end -- Deploy function SWEP:Deploy() end[/code] [editline]2nd August 2017[/editline] Do i need to do the [code]if ( SERVER ) then (Whatever) end[/code]
Sorry, you need to Log In to post a reply to this thread.