i have problem with names -
giorgosdim12 - 22.04.2015
Hello i have one problem ,
can't true name, look this code:
Код:
dcmd_findhouse(playerid,params[])
{
#pragma unused params
new fName[MAX_PLAYER_NAME];
GetPlayerName(playerid,fName,sizeof(fName));
for(new i=0; i<MAX_HOUSES; i++)
{
new hdata[256];
format(hdata,sizeof(hdata),"Houses/UsersHouses/%d.ini",i);
if(HouseInfo[i][hRemoved] == 1)break;
if(HouseInfo[i][hOwner] == strlen(fName)) // here is my problem
{
new str[256];
format(str,sizeof(str),"Find One ID your {00FF00}house{FFFFFF} ({FFFF00}%d{FFFFFF})",i);
SendClientMessage(playerid,-1,str);
}
}
return 1;
}
Re: i have problem with names -
donsta3000 - 22.04.2015
You do realize that "strlen(fName)" is returning the character length of the user's name, it is in no way a valid way of checking their name.
Re: i have problem with names -
Azula - 22.04.2015
use strcmp
PHP код:
if(strcmp(fName, HouseInfo[i][hOwner], false))
Re: i have problem with names -
giorgosdim12 - 23.04.2015
don't working this if(strcmp(fName,HouseInfo[i][hOwner],false)); find only houses with name = 0 -_-
Re: i have problem with names -
Konstantinos - 23.04.2015
Quote:
Originally Posted by Azula
use strcmp
PHP код:
if(strcmp(fName, HouseInfo[i][hOwner], false))
|
It returns 0 when both strings are same so use
! before strcmp.
Re: i have problem with names -
Maximun - 23.04.2015
if(!strcmp(fName, HouseInfo[i][hOwner], false))
Re: i have problem with names -
giorgosdim12 - 23.04.2015
Man with if(!strcmp(fName, HouseInfo[i][hOwner], false)) my send on client 999 houses ids -_-
and with return 0; can't send any message to me only Server:Unkow Command.
Re: i have problem with names -
giorgosdim12 - 23.04.2015
ok i'am create with dialog and working.
now how to get on if(response) to goto my house?
show code :
Код:
dcmd_gotohouse(playerid,params[])
{
#pragma unused params
new data[256];
format(data,sizeof(data),AccData,GetName(playerid));
new id,loop;
for(loop = 0; loop<3; loop++)
{
new f[256];
format(f,sizeof(f),"HouseID_%d",loop);
id = strval(dini_Get(data,f));
new str[256];
format(str,sizeof(str),"House ID: ({FFFF00}%d{FFFFFF})",id);
ShowPlayerDialog(playerid,DIALOG_GOTO_HOUSE,DIALOG_STYLE_LIST,"{00FF00}Your House List",str,"Goto","Exit");
}
return 1;
}
on if(dialogid == DIALOG_GOTO_HOUSE) what use code?
i use HouseInfo[houseid][X, Y,Z];
sorry for bad english...
Re: i have problem with names -
AberKane - 23.04.2015
When using
Код:
if (strcmp(HouseInfo[i][hOwner], fName, false))
Make sure to check if the string is empty or else it will return 0.
So the code should be
Код:
if (strlen(fName) != 0 && strlen(HouseInfo[i][hOwner]) != 0) {
if (strcmp(HouseInfo[i][hOwner], fName, false)) {
// Code goes here
Also make sure that hOwner have enough space to hold the name in your enum or whatever you're using.
Код:
hOwner[MAX_PLAYER_NAME],
For the dialog part |
Use the callback OnDialogResponse
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_GOTO_HOUSE) {
if(!response) return ShowDialog... //Show dialog again, you need to choose.
if(response) {
switch(listitem) {
case 0: EnterHouse(HouseInfo[i][hID]); // 1st place holder for entering the house interior as a function
case 1: ExitHouse(); // 2nd place holder for exiting
}
}
}
//
return true; // Don't forget this return value
}
I recommend using simple commands like /enter - /exit, why wasting dialogs for something ridiculous.
Re: i have problem with names -
giorgosdim12 - 23.04.2015
Yes Man , players have maxinmun 3 houses and case:0 , case:1 , case:2 is for goto to house
and how to get i on dialog response?