How can I make that people who have the Donator Rang get 50 Amor?
In a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerSpawn]GM:PlayerSpawn[/url] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/hook/Add]hook.Add[/url], check the player's rank with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetNWString]Entity:GetNWString[/url] and then [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/SetArmor]Player:SetArmor[/url]
Yes but where do I have to type it?
[QUOTE=xStylo27;51503507]Yes but where do I have to type it?[/QUOTE]
I've always prefered notepad++ but really any text editor will do :v:
I mean in jobs.lua or ...?? xD
I need to type it on any File or not?
[QUOTE=xStylo27;51503556]I mean in jobs.lua or ...?? xD
I need to type it on any File or not?[/QUOTE]
Put it in a new file in lua/autorun/server.
ok thankyou!
[editline]9th December 2016[/editline]
hmm i dont understand the tutorials xD
can you make me a code pls that donator have 50 amor pls
[QUOTE=xStylo27;51503595]ok thankyou!
[editline]9th December 2016[/editline]
hmm i dont understand the tutorials xD
can you make me a code pls that donator have 50 amor pls[/QUOTE]
Try using the links I provided; post your attempt here and we can correct it.
ok
[editline]9th December 2016[/editline]
I think its really bad xD
GM:PlayerSpawn( Player player )
hook.add("PlayerSpawn")
GetNWString( "Donator" )
ply:SetAmor(100)
sry but I am new at GLua or Lua
[editline]9th December 2016[/editline]
what is with this?
if
usergroup=="Donator"
ply:SetAmor(100)
end
hook.Add replaces the GAMEMODE override, which means you can do hook.Add( "PlayerSpawn", ... ) instead. Also, GetNWString is a player function. There's an example at the bottom of the wiki page on how to get usergroups.
For example,
[code]hook.Add("PlayerSpawn, "DonatorArmour", function(ply)
-- Check the usergroup case-insensitive
if (ply:GetNWString("usergroup"):lower() == "donator") then
-- Set the armour here
end
end)[/code]
hook.Add("PlayerSpawn, "DonatorArmor", function(ply)
-- Check the usergroup case-insensitive
if (ply:GetNWString("usergroup"):lower() == "donator") then
ply:SetAmor(100)
end
end)
is this right?
[editline]9th December 2016[/editline]
hook.Add( "PlayerSpawn", "DonatorAmor", function( ply )
if (ply:GetNWString("usergroup"):lower() == "donator") then
ply:SetArmor( 50 )
end)
Your first code is correct, however, you spelled "Armor" incorrectly.
hmm does not work :C
I created a lua file called donator.lua in
lua/autorun/server
Still no amor as a donator
Can you post your exact code in [code] tags?
What is Code tags?
[noparse][code]Code here[/code][/noparse]
[code]hook.Add("PlayerSpawn, "DonatorArmour", function(ply)
-- Check the usergroup case-insensitive
if (ply:GetNWString("usergroup"):lower() == "donator") then
ply:SetAmour(100)
end
end)[/code]
[QUOTE=xStylo27;51504441][code]hook.Add("PlayerSpawn, "DonatorArmour", function(ply)
-- Check the usergroup case-insensitive
if (ply:GetNWString("usergroup"):lower() == "donator") then
ply:SetAmour(100)
end
end)[/code][/QUOTE]
You're missing a quote mark on the first line after PlayerSpawn
You still spelled "Armor" wrong, as well.
Ok I will try it
[editline]9th December 2016[/editline]
Doesnt work
Repost the code. Also, add prints for debugging and make sure the usergroup's exact name is donator.
[code]hook.Add("PlayerSpawn", "DonatorArmour", function(ply)
-- Check the usergroup case-insensitive
if (ply:GetNWString("usergroup"):lower() == "donator") then
ply:SetAmour(100)
end
end)[/code]
I dont know what you mean with prints so yeah
You still haven't spelled Armor right... You should be getting Lua error in the server console explaining that.
[code]hook.Add("PlayerSpawn", "DonatorArmor", function(ply)
-- Check the usergroup case-insensitive
if (ply:GetNWString("usergroup"):lower() == "donator") then
ply:SetArmor(100)
end
end)[/code]
still the same xd
sry but this is REALLY important for me :D
[QUOTE=xStylo27;51505009][code]hook.Add("PlayerSpawn", "DonatorArmor", function(ply)
-- Check the usergroup case-insensitive
if (ply:GetNWString("usergroup"):lower() == "donator") then
ply:SetArmor(100)
end
end)[/code]
still the same xd
sry but this is REALLY important for me :D[/QUOTE]
Add prints and check your server console to make sure it's working. You can add prints by putting this code before and after your if statement:
[code]print("Passed!")[/code]
[code]hook.Add("PlayerSpawn", "DonatorArmor", function(ply)
-- Check the usergroup case-insensitive
if (ply:GetNWString("usergroup"):lower() == "donator") then
ply:SetArmor(100)
print("Passed!")
end
end)[/code]
Is this right?
Put one before the if-statement as well and see what is output when the player is spawned.
[code]hook.Add("PlayerSpawn", "DonatorArmor", function(ply)
-- Check the usergroup case-insensitive
print("Passed!")
if (ply:GetNWString("usergroup"):lower() == "donator") then
ply:SetArmor(100)
print("Passed!")
end
end)[/code]
so?
Now, on spawn, how many times is "Passed!" printed in the server console?
Sorry, you need to Log In to post a reply to this thread.