using CitizenFX.Core;
using static CitizenFX.Core.Native.API;
namespace NoFormatName
{
public class Class1
{
private void HasCon()
{
rescan:;
Wait(300000);
ExecuteCommand("say Test...");
PlayerList players = new PlayerList();
foreach (Player player in players)
{
if (player.Name.Contains("^") || player.Name.Contains("~"))
{
int pID = player.ServerId;
try
{
ExecuteCommand("clientkick " + pID + " Dein Name darf keine Formatierungs-Codes enthalten!");
ExecuteCommand("say Der Spieler (ID: " + pID + ") wurde gekickt!");
}
catch
{
ExecuteCommand("say Der Spieler (ID: " + pID + ") konnte nicht vom Server geworfen werden!");
}
goto rescan;
}
goto rescan;
}
}
}
}
Did i forget something or made a mistake? I couldnt find a mistake.
Well, your code will wait 300000 ms (~83 minutes) before running anything below that Wait. Move the ExecuteCommand before that in order for it to actually be ran.
In addition, do you have any other script calling this method? If that is the only C# code you have, that is not setup properly.
@Briglair ye, i just calculated it again, i still got 300000ms. But why doesnt the script run then? Do i need to tell it, that it needs to run the void HasCon();?
Hey i need help badly so i made a script that attaches a flashlight to a pistol if u have it and it worked without perms when i tried to add perms it didnt work here are all my things:-
CLIENT.LUA
RegisterNetEvent("Police:GiveFlash")
AddEventHandler("Police:GiveFlash", function()
if HasPedGotWeapon(PlayerPedId(), "weapon_pistol", 0) then
GiveWeaponComponentToPed(PlayerPedId(), "weapon_pistol", "COMPONENT_AT_PI_FLASH")
end
end)
SERVER.LUA
RegisterCommand("flash", function(source, args, rawCommand)
if IsPlayerAceAllowed(source, "police.flash") then
TriggerClientEvent("Police:GiveFlash", source)
end
end, false)
It looks like it yeah. Just remove that top one completely as it does absolutely nothing. Just use the bottom one with your steam and then change it to add_ace instead. That should work.