Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
2.0 kB
7
Indexable
Never
// Thêm mới
task updateHealCotDien[60000]() { // 60000 = 1 phút
	for(new i = 0; i < sizeof(ThoDienInfo); i++) {
		if(ThoDienInfo[i][td_posX] != 0) {
			ThoDienInfo[i][td_tinhTrang] -= random(5);
			if(ThoDienInfo[i][td_tinhTrang] <= 0) {
				ThoDienInfo[i][td_tinhTrang] = 0;
				ThoDienInfo[i][td_cupDien] = 1;
			}
		}
	}
}

// Sửa
forward SuaCauThang(playerid);
public SuaCauThang(playerid)
{
    SetPVarInt(playerid, "SuaCauThangTime", GetPVarInt(playerid, "SuaCauThangTime")-1);

    new i = GetPVarInt(playerid, "cotdienID");
    ThoDienInfo[i][td_tinhTrang] += 1;

    new string[1280], strCotDien[1280];
    format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~w~Dang sua dien~n~~r~%d~w~/~g~%d", ThoDienInfo[i][td_tinhTrang], 100);
    GameTextForPlayer(playerid, string, 1100, 3);

    format(strCotDien, sizeof(strCotDien), "- {00ff00}COT DIEN #%d{FFFFFF} -\n\nTinh trang : %s (%d%%)", i+1, tinhtrang_cotdien(ThoDienInfo[i][td_tinhTrang]), ThoDienInfo[i][td_tinhTrang]);
    UpdateDynamic3DTextLabelText(ThoDienInfo[i][tdLabel], -1, strCotDien);

    if(GetPVarInt(playerid, "SuaCauThangTime") > 0) SetTimerEx("SuaCauThang", 1000, 0, "d", playerid);

    if(ThoDienInfo[i][td_tinhTrang] >= 100)
    {
        DeletePVar(playerid, "SuaCauThangTime");
        DeletePVar(playerid, "SuaCauThang");

        SetPVarInt(playerid, "cotdienID", -1);

        RemovePlayerAttachedObject(playerid, 0);
        TogglePlayerControllable(playerid, 1);
    	ClearAnimations(playerid);

    	PlayerInfo[playerid][pCash] += 5000;
    	cmd_me(playerid, "da sua thanh cong cay cot dien.");

    	leocauthang[playerid] = 0;
		SetPlayerPos(playerid, ThoDienInfo[i][td_posX], ThoDienInfo[i][td_posY] - (0.15 + 0.5), ThoDienInfo[i][td_posZ] + 2.0);
		SetPlayerFacingAngle(playerid, ThoDienInfo[i][td_posR]);
		TogglePlayerControllable(playerid, 1);
		leocauthangTimer[playerid] = gettime() + 5;

		ThoDienInfo[i][td_cupDien] = 0;
    	return 1;
	}
	return 1;
}
Leave a Comment