echoHU Posted November 18, 2018 Share Posted November 18, 2018 Hello! I want to make a function to check an existing player with the same username i am logging in to the server. public static bool IsPlayerExist( string username ) { for ( int i = 0; i < NAPI.Server.GetMaxPlayers(); i++) { if ( NAPI.Data.GetEntityData(NAPI.Player.GetPlayerFromHandle(i), "player.username") == username ) { return false; } } return true; } it says: " cannot convert from 'int' to 'GTANetworkAPI.NetHandle' " I would be grateful if you could tell me how to convert or make this script in a correct way. Link to comment Share on other sites More sharing options...
CMHDev Posted November 23, 2018 Share Posted November 23, 2018 (edited) public static IdOrName client ( intrare string ) { Client tinta = null ; var tipInput = int . TryParse ( intrare , ieșire var id ); dacă ( tipInput ) { foreach ( var jucător în NAPI . bazine . GetAllPlayers ()) { dacă ( jucător . Valoare =! id ) continuă ; tinta = jucător ; pauza ; } } altfel { foreach ( var jucător în NAPI . bazine . GetAllPlayers ()) { var playerName = player . Nume . ToUpper (); în cazul în care ( ! playerName . Conține ( intrare . toupper ())) continue ; tinta = jucător ; pauza ; } } retur tinta ; } EX pentru utilizare : [ Comandă ( "test" )] public void CMD_Test ( client client , player de șir ) { var target = Funcție . IdOrName ( player ); dacă ( țintă ! = nulă ) { client . SendChatMessage ( $ "Jucătorul a găsit { target . Name }" ); } altfel { client . SendChatMessage ( "Jucătorul nu a găsit!" ); } } This is all you need Edited November 23, 2018 by CMHDev Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now