Hello I would like to create a pve pvp function

so I would like when we activate the pvp that nobody can kill you anymore and that you can not kill anyone in return except the NPC

with this line of code it does not work

RegisterCommand(‘pve’, function()

SetCanAttackFriendly(GetPlayerPed(-1), false, false)

NetworkSetFriendlyFireOption(false)

print("pve")


end

end, false)

RegisterCommand(‘pvp’, function()

SetCanAttackFriendly(GetPlayerPed(-1), true, true)

NetworkSetFriendlyFireOption(true)

print("pvp")

end, false)

tks for any help