Jump to content

Problema case


NighTeN

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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