Jump to content

Recommended Posts

Posted

Salut! Am si eu o problema la sistemul de case, vreau sa fac in asa fel sa apara chiriasi ce au dat rent. M-am tot uitat prin alte gamemode-uri sa ma inspir poate ma ajuta, dar nimic, ba imi arata numele meu la chiriasi la unele verificari si alte ori nu apare niciun nume.

stock ShowRenters(playerid)
{
    gQuery[0] = EOS;
    new id, name[24], string[128];
    
    mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `House` = '%d' LIMIT 50", PlayerInfo[playerid][pHouse]);
    mysql_pquery(SQL, gQuery, "", "");
    new Cache: result = mysql_query(SQL, gQuery);
    
    cache_get_field_content(id, "Name", name);
    format(name, sizeof(name), PlayerInfo[id][pName]);
    if(id != INVALID_PLAYER_ID)
        return format(string, sizeof(string), "%s (Online)\n", GetName(id)); 
    
    format(string, sizeof(string), "%s (Offline)\n", GetName(id));
    Dialog_Show(playerid, DIALOG_RENTERS, DIALOG_STYLE_LIST, "Renters", string, "Select", "Cancel");
    cache_delete(result);
    
    return true;
}

Acesta este stock-ul pe care am incercat sa il fac, daca m-ati putea ajuta ar fi bine.

Posted (edited)
ShowRenters(playerid) {
	new sQuery[256], string[180], MemberString[1024], szResult[180];
	new name[180], TitleString[180], tmembers, onmembers;
	format(sQuery, sizeof(sQuery), "SELECT * FROM `users` WHERE `Rented` = %d LIMIT 50", PlayerInfo[playerid][pHouse]);
	new Cache: result = mysql_query(SQL, sQuery);
	for(new i, j = cache_get_row_count(); i != j; ++i)
	{
		cache_get_field_content(i, "name", szResult); format(name, 256, szResult);
		new userID = GetPlayerID(name);
		if(userID != INVALID_PLAYER_ID) {
			onmembers++;
			format(string, sizeof(string), "%d. %s (%d) (Online)\n", tmembers+1, name, userID);
			strcat(MemberString, string, sizeof(MemberString));
		}
		else {
			format(string, sizeof(string), "%d. %s (Offline)\n", tmembers+1, name);
			strcat(MemberString, string, sizeof(MemberString));
		}
		tmembers++;
	}
	cache_delete(result);
	format(TitleString, sizeof(TitleString), "Chiriasi (%d/%d)", onmembers, tmembers);
	ShowPlayerDialog(playerid, DIALOG_RENTERS, DIALOG_STYLE_LIST, TitleString, MemberString, "OK", "Close");
	return 1;
}


Eu asa am functia.
Daca nu ai `Rented` in `users`, poti inlocui cum ai tu, adica in loc de `Rented` inlocuiesti cu `House`
 

stock GetPlayerID(playerName[]) {
  	foreach(new i: Player) {
    	if(IsPlayerLogged[i] == 1) {
      		if(strcmp(PlayerInfo[i][pUsername], playerName, true) == 0) return i;
    	}
  	}
  	return INVALID_PLAYER_ID;
}

Ti-am lasat aici si functia GetPlayerID in caz ca nu o ai.

Edited by Akan

Discord:
! Akan !#6675

Posted
On 5/12/2020 at 12:39 PM, Akan said:

ShowRenters(playerid) {
	new sQuery[256], string[180], MemberString[1024], szResult[180];
	new name[180], TitleString[180], tmembers, onmembers;
	format(sQuery, sizeof(sQuery), "SELECT * FROM `users` WHERE `Rented` = %d LIMIT 50", PlayerInfo[playerid][pHouse]);
	new Cache: result = mysql_query(SQL, sQuery);
	for(new i, j = cache_get_row_count(); i != j; ++i)
	{
		cache_get_field_content(i, "name", szResult); format(name, 256, szResult);
		new userID = GetPlayerID(name);
		if(userID != INVALID_PLAYER_ID) {
			onmembers++;
			format(string, sizeof(string), "%d. %s (%d) (Online)\n", tmembers+1, name, userID);
			strcat(MemberString, string, sizeof(MemberString));
		}
		else {
			format(string, sizeof(string), "%d. %s (Offline)\n", tmembers+1, name);
			strcat(MemberString, string, sizeof(MemberString));
		}
		tmembers++;
	}
	cache_delete(result);
	format(TitleString, sizeof(TitleString), "Chiriasi (%d/%d)", onmembers, tmembers);
	ShowPlayerDialog(playerid, DIALOG_RENTERS, DIALOG_STYLE_LIST, TitleString, MemberString, "OK", "Close");
	return 1;
}


Eu asa am functia.
Daca nu ai `Rented` in `users`, poti inlocui cum ai tu, adica in loc de `Rented` inlocuiesti cu `House`
 


stock GetPlayerID(playerName[]) {
  	foreach(new i: Player) {
    	if(IsPlayerLogged[i] == 1) {
      		if(strcmp(PlayerInfo[i][pUsername], playerName, true) == 0) return i;
    	}
  	}
  	return INVALID_PLAYER_ID;
}

Ti-am lasat aici si functia GetPlayerID in caz ca nu o ai.

Cand afisez renteri la casa imi apare numele meu.

Posted

Pentru ca ai inlocuit probabil `Rented` cu `House` si te arata si pe tine pt. ca si tu ai `House` = cu acea casa.
Fa-ti variabila `Rented` cum o am eu ca sa iti arate doar Renterii.

Discord:
! Akan !#6675

Posted
7 hours ago, Akan said:

Pentru ca ai inlocuit probabil `Rented` cu `House` si te arata si pe tine pt. ca si tu ai `House` = cu acea casa.
Fa-ti variabila `Rented` cum o am eu ca sa iti arate doar Renterii.

Nu, am pus rent cum era la mine si imi arata numele meu, nu am pus house.

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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.