Traité [AIDE] Me faire le côté SERVER svp

Braazh

Membre 🏅
Level 2

Torrents Stats

Messages
16
J'aime
0
Trophées
25
Inscrit
2 Mai 2017
Bonjour/Bonsoir,

Je voudrais que vous m'aidez s'il vous plaît à me faire le côté SERVER car actuellement j'ai que le côté CLIENT :

Voici le code côté CLIENT :

Code:
-----------------------------------------------------
if SERVER then
    resource.AddFile( "materials/microphone.png" )
    
    hook.Add( "PlayerCanHearPlayersVoice", "VoiceEditSystemHookCanHear", function( listener, talker )
        if talker:GetNWInt("VoiceSystemEditNW") == 0 and listener:GetPos():Distance( talker:GetPos() ) > 100 then return false end
        if talker:GetNWInt("VoiceSystemEditNW") == 1 and listener:GetPos():Distance( talker:GetPos() ) > 300 then return false end
        if talker:GetNWInt("VoiceSystemEditNW") == 2 and listener:GetPos():Distance( talker:GetPos() ) > 600 then return false end
    end )

    hook.Add( "PlayerInitialSpawn", "VoiceEditSystemHookInitSpawn", function(ply)
        ply:SetNWInt("VoiceSystemEditNW",1)
    end)

    hook.Add( "PlayerSay", "VoiceEditSystemHookSay", function( ply, text, public )
        text = string.lower( text ) -- Make the chat message entirely lowercase
        if ( text == "/changevoice" ) then
            ply:SetNWInt("VoiceSystemEditNW",ply:GetNWInt("VoiceSystemEditNW") + 1)
            if ply:GetNWInt("VoiceSystemEditNW") == 3 then ply:SetNWInt("VoiceSystemEditNW",0) end
            if ply:GetNWInt("VoiceSystemEditNW") == 0 then
                ply:ChatPrint("Vous parlez bas")
            end
            if ply:GetNWInt("VoiceSystemEditNW") == 1 then
                ply:ChatPrint("Vous parlez normalement")
            end
            if ply:GetNWInt("VoiceSystemEditNW") == 2 then
                ply:ChatPrint("Vous parlez fortement")
            end
            return ""
        end
    end )
end

if CLIENT then
    hook.Add( "HUDPaint", "VoiceEditSystemHookHUD", function()
        if LocalPlayer():IsSpeaking() then
            surface.SetDrawColor( 30, 30, 30, 255 )
            surface.SetMaterial( Material("materials/microphone.png"))
            surface.DrawTexturedRect( ScrW() - 55, 5, 32,32 )
            draw.RoundedBoxEx( 4, ScrW() - 180,12,130,20,Color(0, 0, 0, 240), true, false, true, false )
            if ply:GetNWInt("VoiceSystemEditNW") == 0 then
                draw.SimpleText("Chuchotement ( F6 )","Trebuchet18",ScrW() - 175,13,Color(47, 179, 43, 150))
            end
            if ply:GetNWInt("VoiceSystemEditNW") == 1 then
                draw.SimpleText("Normalement ( F6 )","Trebuchet18",ScrW() - 175,13,Color(47, 179, 43, 150))
            end
            if ply:GetNWInt("VoiceSystemEditNW") == 2 then
                draw.SimpleText("Fortement ( F6 )","Trebuchet18",ScrW() - 175,13,Color(47, 179, 43, 150))
            end
            --draw.SimpleText("F6 pour changer le mode de parole","Trebuchet18",ScrW() - 150,10,Color(0,255,0),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
        end
    end )

    hook.Add( "Think", "VoiceEditSystemHookKeyDown", function()
        if input.IsKeyDown(KEY_F6) then
            LocalPlayer():ConCommand("say /changevoice")
        end
    end )
end

Merci d'avance :)
 

unknown

Membre ✓
Certifié
Level 3

Torrents Stats

Messages
167
J'aime
1 451
Trophées
893
Inscrit
25 Avril 2017
Désolé mais personne ne te le fera gratuitement.
 

One.

Administrator/Dev
Administrateur
Level 5

Torrents Stats

Messages
579
J'aime
5 683
Trophées
1 869
Inscrit
24 Décembre 2015
Bonjour/Bonsoir,

Je voudrais que vous m'aidez s'il vous plaît à me faire le côté SERVER car actuellement j'ai que le côté CLIENT :

Voici le code côté CLIENT :

Code:
-----------------------------------------------------
if SERVER then
    resource.AddFile( "materials/microphone.png" )
   
    hook.Add( "PlayerCanHearPlayersVoice", "VoiceEditSystemHookCanHear", function( listener, talker )
        if talker:GetNWInt("VoiceSystemEditNW") == 0 and listener:GetPos():Distance( talker:GetPos() ) > 100 then return false end
        if talker:GetNWInt("VoiceSystemEditNW") == 1 and listener:GetPos():Distance( talker:GetPos() ) > 300 then return false end
        if talker:GetNWInt("VoiceSystemEditNW") == 2 and listener:GetPos():Distance( talker:GetPos() ) > 600 then return false end
    end )

    hook.Add( "PlayerInitialSpawn", "VoiceEditSystemHookInitSpawn", function(ply)
        ply:SetNWInt("VoiceSystemEditNW",1)
    end)

    hook.Add( "PlayerSay", "VoiceEditSystemHookSay", function( ply, text, public )
        text = string.lower( text ) -- Make the chat message entirely lowercase
        if ( text == "/changevoice" ) then
            ply:SetNWInt("VoiceSystemEditNW",ply:GetNWInt("VoiceSystemEditNW") + 1)
            if ply:GetNWInt("VoiceSystemEditNW") == 3 then ply:SetNWInt("VoiceSystemEditNW",0) end
            if ply:GetNWInt("VoiceSystemEditNW") == 0 then
                ply:ChatPrint("Vous parlez bas")
            end
            if ply:GetNWInt("VoiceSystemEditNW") == 1 then
                ply:ChatPrint("Vous parlez normalement")
            end
            if ply:GetNWInt("VoiceSystemEditNW") == 2 then
                ply:ChatPrint("Vous parlez fortement")
            end
            return ""
        end
    end )
end

if CLIENT then
    hook.Add( "HUDPaint", "VoiceEditSystemHookHUD", function()
        if LocalPlayer():IsSpeaking() then
            surface.SetDrawColor( 30, 30, 30, 255 )
            surface.SetMaterial( Material("materials/microphone.png"))
            surface.DrawTexturedRect( ScrW() - 55, 5, 32,32 )
            draw.RoundedBoxEx( 4, ScrW() - 180,12,130,20,Color(0, 0, 0, 240), true, false, true, false )
            if ply:GetNWInt("VoiceSystemEditNW") == 0 then
                draw.SimpleText("Chuchotement ( F6 )","Trebuchet18",ScrW() - 175,13,Color(47, 179, 43, 150))
            end
            if ply:GetNWInt("VoiceSystemEditNW") == 1 then
                draw.SimpleText("Normalement ( F6 )","Trebuchet18",ScrW() - 175,13,Color(47, 179, 43, 150))
            end
            if ply:GetNWInt("VoiceSystemEditNW") == 2 then
                draw.SimpleText("Fortement ( F6 )","Trebuchet18",ScrW() - 175,13,Color(47, 179, 43, 150))
            end
            --draw.SimpleText("F6 pour changer le mode de parole","Trebuchet18",ScrW() - 150,10,Color(0,255,0),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
        end
    end )

    hook.Add( "Think", "VoiceEditSystemHookKeyDown", function()
        if input.IsKeyDown(KEY_F6) then
            LocalPlayer():ConCommand("say /changevoice")
        end
    end )
end

Merci d'avance :)
Si je m'en tiens à ton code, y'a pas de coté server, met ce code en shared et c'est ok.
 

One.

Administrator/Dev
Administrateur
Level 5

Torrents Stats

Messages
579
J'aime
5 683
Trophées
1 869
Inscrit
24 Décembre 2015
(Juste au cas ou "if SERVER then" signifie que c'est un code serveur..)
 

Braazh

Membre 🏅
Level 2

Torrents Stats

Messages
16
J'aime
0
Trophées
25
Inscrit
2 Mai 2017
@One. ça me fait une erreur :


Code:
[ERROR] addons/voice_system/lua/autorun/shared.lua:40: attempt to index global 'ply' (a nil value)
  1. fn - addons/voice_system/lua/autorun/shared.lua:40
   2. unknown - addons/ulib/lua/ulib/shared/hook.lua:109
 

One.

Administrator/Dev
Administrateur
Level 5

Torrents Stats

Messages
579
J'aime
5 683
Trophées
1 869
Inscrit
24 Décembre 2015
@One. ça me fait une erreur :


Code:
[ERROR] addons/voice_system/lua/autorun/shared.lua:40: attempt to index global 'ply' (a nil value)
  1. fn - addons/voice_system/lua/autorun/shared.lua:40
   2. unknown - addons/ulib/lua/ulib/shared/hook.lua:109
Tiens met ça :
Bash:
-----------------------------------------------------
if SERVER then
    resource.AddFile( "materials/microphone.png" )
    
    hook.Add( "PlayerCanHearPlayersVoice", "VoiceEditSystemHookCanHear", function( listener, talker )
        if talker:GetNWInt("VoiceSystemEditNW") == 0 and listener:GetPos():Distance( talker:GetPos() ) > 100 then return false end
        if talker:GetNWInt("VoiceSystemEditNW") == 1 and listener:GetPos():Distance( talker:GetPos() ) > 300 then return false end
        if talker:GetNWInt("VoiceSystemEditNW") == 2 and listener:GetPos():Distance( talker:GetPos() ) > 600 then return false end
    end )

    hook.Add( "PlayerInitialSpawn", "VoiceEditSystemHookInitSpawn", function(ply)
        ply:SetNWInt("VoiceSystemEditNW",1)
    end)

    hook.Add( "PlayerSay", "VoiceEditSystemHookSay", function( ply, text, public )
        text = string.lower( text ) -- Make the chat message entirely lowercase
        if ( text == "/changevoice" ) then
            ply:SetNWInt("VoiceSystemEditNW",ply:GetNWInt("VoiceSystemEditNW") + 1)
            if ply:GetNWInt("VoiceSystemEditNW") == 3 then ply:SetNWInt("VoiceSystemEditNW",0) end
            if ply:GetNWInt("VoiceSystemEditNW") == 0 then
                ply:ChatPrint("Vous parlez bas")
            end
            if ply:GetNWInt("VoiceSystemEditNW") == 1 then
                ply:ChatPrint("Vous parlez normalement")
            end
            if ply:GetNWInt("VoiceSystemEditNW") == 2 then
                ply:ChatPrint("Vous parlez fortement")
            end
            return ""
        end
    end )
end

if CLIENT then
    hook.Add( "HUDPaint", "VoiceEditSystemHookHUD", function()
        if LocalPlayer():IsSpeaking() then
            surface.SetDrawColor( 30, 30, 30, 255 )
            surface.SetMaterial( Material("materials/microphone.png"))
            surface.DrawTexturedRect( ScrW() - 55, 5, 32,32 )
            draw.RoundedBoxEx( 4, ScrW() - 180,12,130,20,Color(0, 0, 0, 240), true, false, true, false )
            if LocalPlayer():GetNWInt("VoiceSystemEditNW") == 0 then
                draw.SimpleText("Chuchotement ( F6 )","Trebuchet18",ScrW() - 175,13,Color(47, 179, 43, 150))
            end
            if LocalPlayer():GetNWInt("VoiceSystemEditNW") == 1 then
                draw.SimpleText("Normalement ( F6 )","Trebuchet18",ScrW() - 175,13,Color(47, 179, 43, 150))
            end
            if LocalPlayer():GetNWInt("VoiceSystemEditNW") == 2 then
                draw.SimpleText("Fortement ( F6 )","Trebuchet18",ScrW() - 175,13,Color(47, 179, 43, 150))
            end
            --draw.SimpleText("F6 pour changer le mode de parole","Trebuchet18",ScrW() - 150,10,Color(0,255,0),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
        end
    end )

    hook.Add( "Think", "VoiceEditSystemHookKeyDown", function()
        if input.IsKeyDown(KEY_F6) then
            LocalPlayer():ConCommand("say /changevoice")
        end
    end )
end
 

Braazh

Membre 🏅
Level 2

Torrents Stats

Messages
16
J'aime
0
Trophées
25
Inscrit
2 Mai 2017
@One. Merci à toi, il marche parfaitement, tu peux le mettre en "Traité" :)
 
Haut Bas