Please elaborate?
Woops yea, forgot to inherit from BaseScript
.
I just copy pasted his code.
Make sure you are using the right dll (server side) and inherit from BaseScript. This exposes you to the right classes.
Project settings > debug > advanced > embedded
I think, but might be some other place but Iāll have to check in Vishal studio once Iāve got time.
Well yeah idk then, youāll have to translate it.
@Vespura actually i know what these words mean in german, but in Visual Studio i just cant find themā¦
Maybe you can tell me, what i have to tick, am i even in the right settings?
Yes indeed its under Project Settings -> Build -> Advanced -> Set debug information to embedded
Normally server and client would have the Player.Handle
property, Iām wondering why heād get such an error. Maybe old binaries??
using CitizenFX.Core;
using System.Threading.Tasks;
namespace NoFormatName
{
public class Class1 : BaseScript
{
public Class1()
{
Tick += OnTick;
}
private async Task OnTick()
{
rescan:
await Delay(300000);
PlayerList players = new PlayerList();
foreach (Player player in players)
{
if (player.Name.Contains("^1") || player.Name.Contains("^~") || player.Name.Contains("^2") || player.Name.Contains("^3") || player.Name.Contains("^4") || player.Name.Contains("^5") || player.Name.Contains("^6") || player.Name.Contains("^6") || player.Name.Contains("^7") || player.Name.Contains("^8") || player.Name.Contains("^9") || player.Name.Contains("^*") || player.Name.Contains("^_") || player.Name.Contains("^=") || player.Name.Contains("^*^"))
{
int pID = player.ServerId;
Debug.WriteLine("clientkick " + pID + " Dein Name darf keine Formatierungs-Codes enthalten!");
Debug.WriteLine("say Der Spieler (ID: " + pID + ") wurde gekickt!");
goto rescan;
}
goto rescan;
}
goto rescan;
}
}
}
Why are you using rescan??? Take that out (see my code snippet).
This handler OnTick will run every tick.
@d0p3t so waitā¦
if i do it like this:
using CitizenFX.Core;
using System.Threading.Tasks;
namespace NoFormatName
{
public class Class1 : BaseScript
{
public Class1()
{
Tick += OnTick;
}
private async Task OnTick()
{
await Delay(300000);
PlayerList players = new PlayerList();
foreach (Player player in players)
{
if (player.Name.Contains("^1") || player.Name.Contains("^~") || player.Name.Contains("^2") || player.Name.Contains("^3") || player.Name.Contains("^4") || player.Name.Contains("^5") || player.Name.Contains("^6") || player.Name.Contains("^6") || player.Name.Contains("^7") || player.Name.Contains("^8") || player.Name.Contains("^9") || player.Name.Contains("^*") || player.Name.Contains("^_") || player.Name.Contains("^=") || player.Name.Contains("^*^"))
{
int pID = player.ServerId;
Debug.WriteLine("clientkick " + pID + " Dein Name darf keine Formatierungs-Codes enthalten!");
Debug.WriteLine("say Der Spieler (ID: " + pID + ") wurde gekickt!");
}
}
}
}
}
will the code then still check every 5 minutes? And does it use more server-resources?
Yes exactly. A tick is exactly what it says. A server runs on a certain tick rate. And so does the client (usually similar to amount of frames).
Specifics for FiveM isnāt important but just now that when adding a tick to Tick
( like you do with OnTick in the constructor), it will runs OnTick every tick. Continuously. In this case this particular OnTick function will wait 300000ms until it continues.
Then it wouldnāt check every 5 minutes
@d0p3t then it would check on every tick, right?
But with the delayā¦ doesnt it start the delay on every tick then?
OnTick blocks until its done and then will run again
await Delay(300000) will pretty much skip 300000 ticks
@d0p3t ahh okay, thanks
but now: why do i get the error? Something wrong when i use player.ServerId and / or player.Handle dont they exist?