cstef4n Posted May 19 Posted May 19 (edited) Cum pot face sa seteze automat random vremea pe server cu ID-urile (weather) alese de mine Exemplu: Vreau sa seteze automat weather cu ID-urile 1,2,3,5,9,12,15 Edited May 19 by cstef4n
0 khain.dev Posted May 26 Posted May 26 #include <a_samp> // Intervalul de timp în milisecunde (Ex: 30 de minute = 30 * 60 * 1000) #define WEATHER_TIMER_DELAY (30 * 60 * 1000) // Lista cu ID-urile de vreme alese de tine new const ValidWeathers[] = {1, 2, 3, 5, 9, 12, 15}; public OnGameModeInit() { // Pornim timerul care va apela funcția "ChangeRandomWeather" periodic SetTimer("ChangeRandomWeather", WEATHER_TIMER_DELAY, true); // Opțional: Setăm o vreme random chiar și când se deschide serverul ChangeRandomWeather(); return 1; } forward ChangeRandomWeather(); public ChangeRandomWeather() { // random(sizeof(ValidWeathers)) alege un index la întâmplare din vector new randomIndex = random(sizeof(ValidWeathers)); new newWeather = ValidWeathers[randomIndex]; // Setăm vremea globală pe server SetWeather(newWeather); // Trimitem un mesaj informativ tuturor jucătorilor (opțional) new string[64]; format(string, sizeof(string), "{FF9900}[Server]{FFFFFF} Vremea a fost schimbată (ID: %d).", newWeather); SendClientMessageToAll(-1, string); return 1; } /* sizeof(ValidWeathers): Află automat câte ID-uri ai pus în listă (în cazul tău, 7 ID-uri). Dacă pe viitor vrei să adaugi și ID-ul 7, doar îl treci în array {1, 2, 3, 5, 9, 12, 15, 7} și codul se va adapta singur. random(...): Extrage o poziție din listă (de la 0 la 6). SetWeather(newWeather): Schimbă vremea pentru toți jucătorii care se conectează sau sunt deja pe server.*/
Question
cstef4n
Cum pot face sa seteze automat random vremea pe server cu ID-urile (weather) alese de mine
Exemplu: Vreau sa seteze automat weather cu ID-urile 1,2,3,5,9,12,15
Edited by cstef4n1 answer to this question
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