Jump to content

[Tutorial]Rainbow Baza


ASGOOD
 Share

Recommended Posts

  • Retired
new TimerRainbow[MAX_PLAYERS];//definim timer-ul

forward RainbowTimer(playerid);//cream forward-ul pentru viitorul timer
public RainbowTimer(playerid) { // public-ul
    new carcol[2];//Definim 2 variabile (scurtaturi)
	new carid = GetPlayerVehicleID(playerid);//inca o scurtatura
	carcol[0] = randomEx(165, 255), carcol[1] = randomEx(165, 255);//Conferim valorile scurtaturilor
	ChangeVehicleColor(carid, carcol[0], carcol[1]);//Schimbam culoarea vehiculului
	return 1;
}
CMD:rainbowon(playerid, params[]){//Cream comanda
	new ptime;//definim o variabila pe care sa o cautam cu sscanf cand tasteaza comanda
	if(TimerRainbow[playerid] != -1)return SendClientMessage(playerid, 0xFFFFFF77, "Ai pornit deja rainbow-ul");//Verificam daca are pornit rainbow-ul
	if(sscanf(params, "i", ptime))return SendClientMessage(playerid, 0xFFFFFF77, "Use: /rainbowon <time in seconds>");//verificam daca scrie comanda corect
	if(ptime < 1 || ptime > 10)return SendClientMessage(playerid, 0xFFFFFF77, "Poti pune doar intre 1 si 10 secunde.");//o interogatie sa nu puna mai putin de 1s si nici mai mult de 10s
	if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid, 0xFFFFFF77, "Nu esti intr-un vehicul.");//Verificam daca este intr-un vehicul
	TimerRainbow[playerid] = SetTimerEx("RainbowTimer", ptime*1000, true, "i", playerid);//Setam timer-ul
	SendClientMessage(playerid, 0xFFFF00FF, "Ai pornit rainbow-ul.");//Ii trimitem un mesaj
	return 1;//finish
}
CMD:rainbowoff(playerid, params[]){//creem comanda
	if(TimerRainbow[playerid] == -1)return SendClientMessage(playerid, 0xFFFFFF77, "Nu ai pornit rainbow-ul"); //Verificam daca-l are pornit
	KillTimer(TimerRainbow[playerid]);//Oprim timer-ul
	SendClientMessage(playerid, 0xFFFF00FF, "Ai oprit rainbow-ul.");//trimitem mesaj-ul
	return 1;//finish
}
public OnPlayerExitVehicle(playerid, vehicleid) {//Cand player-ul iese din vehicul
	if(TimerRainbow[playerid] != -1){//Verificam daca are rainbow-ul pornit
    	KillTimer(TimerRainbow[playerid]); //Daca il are, il oprim
    }
	return 1; 
}

Scz @AlexxAdv, multi nu au y_timers sau nu stiu sa-l foloseasca :))

Edited by ASGOOD

ASGOOD#8460

forum.png

Link to comment
Share on other sites

Bv

    _________________________________________________
    |                                                        _________             |
    |    |    /          /|        |\            |      /                   \          |
    |    |  /        /   |          |  \          |      |                              |
    |    |/       /     |           |    \        |      |                              |   
    |    |\              |           |      \      |      |        _____            |
    |    |  \            |           |        \    |      |                 \           |
    |    |    \          |           |          \  |      |                   |          |
    |    |      \        |           |            \|      \_________/           |
    |_______________________________________________|

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...