DynamicCP Don't work
#1

Hello i have this probblem with DynamicCP,can you help me?
When you enter in a DYNAMICCP server don't say the messages,i don't know what to do..

Код:
Houses[idx][PickupID] = CreateDynamicCP(Houses[idx][EnterX], Houses[idx][EnterY], Houses[idx][EnterZ], 1.4, -1, -1, -1, 1.4);
Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
    	new string[128];
	    for (new c=0; c<MAX_HOUSES; c++)
		{
			if (PlayerToPoint(1.4,playerid,Houses[c][EnterX], Houses[c][EnterY], Houses[c][EnterZ]))
			{
			    if(Houses[c][HousePrice] != 0)
			    {
				    if(Houses[c][Owned] == 0)
				    {
						SendClientMessage(playerid, COLOR_GREEN, "Doresti sa cumperi aceasta proprietate?");
						format(string, sizeof(string), "Price: $%d", Houses[c][HousePrice]);
				    	SendClientMessage(playerid, COLOR_GREEN, string);
				    	SendClientMessage(playerid, COLOR_WHITE, "Available commands: /buyhouse, /enter, /ds(hout)");
					}
					else
					{
					    if(Houses[c][Rentable] == 1)
					    {
					        new string2[128];
							format(string, sizeof(string), "[Adress: %d] You're standing on %s's porch.",c,Houses[c][Owner]);
					    	SendClientMessage(playerid, COLOR_GREEN, string);
							format(string2, sizeof(string2), "Available commands: /enter, /ds(hout), /rentroom (Price: $%d)", Houses[c][RentCost]);
				    		SendClientMessage(playerid, COLOR_WHITE, string2);
					    }
					    else
					    {
							format(string, sizeof(string), "[Adress: %d] You're standing on %s's porch",c,Houses[c][Owner]);
					    	SendClientMessage(playerid, COLOR_GREEN, string);
					    	SendClientMessage(playerid, COLOR_WHITE, "Available commands: /enter, /ds(hout)");
				    	}
					}
				}
			}
		}
	}
	return 1;
}
Reply
#2

Up
Reply
#3

Try adding a printf statement at the top of the callback to see if it's the code not working properly, or the callback that isn't called properly.

PHP код:
public OnPlayerEnterDynamicCP(playeridcheckpointid)
{
    
printf("Player %i entering dynamic checkpoint %i"playeridcheckpointid); 
If that works, the checkpoints are working.

On the other hand, try a range of 1.5 for your PlayerToPoint function, but still create them with a diameter of 1.4.
The player may enter the checkpoint, but he could be at 1.401 meters distance and your code will fail of course, just because of floating point inaccuracies.
Reply
#4

Also it won't send any of the messages if Houses[c][HousePrice] is 0.

By the way, why do you use PlayerToPoint when there is IsPlayerInRangeOfPoint as a native (much faster)?
Reply
#5

All house prices is 15000$ or 20000$

The new code after when i try all your suggestions:

Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    printf("Player %i entering dynamic checkpoint %i", playerid, checkpointid);
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
    	new string[128];
	    for (new c=0; c<MAX_HOUSES; c++)
		{
 			if(checkpointid == Houses[c][PickupID])
			{
				if (IsPlayerInRangeOfPoint(1.5,playerid,Houses[c][EnterX], Houses[c][EnterY], Houses[c][EnterZ]))
				{
				    if(Houses[c][HousePrice] != 0)
				    {
					    if(Houses[c][Owned] == 0)
					    {
							SendClientMessage(playerid, COLOR_GREEN, "Doresti sa cumperi aceasta proprietate?");
							format(string, sizeof(string), "Price: $%d", Houses[c][HousePrice]);
					    	SendClientMessage(playerid, COLOR_GREEN, string);
					    	SendClientMessage(playerid, COLOR_WHITE, "Available commands: /buyhouse, /enter, /ds(hout)");
						}
						else
						{
						    if(Houses[c][Rentable] == 1)
						    {
						        new string2[128];
								format(string, sizeof(string), "[Adress: %d] You're standing on %s's porch.",c,Houses[c][Owner]);
						    	SendClientMessage(playerid, COLOR_GREEN, string);
								format(string2, sizeof(string2), "Available commands: /enter, /ds(hout), /rentroom (Price: $%d)", Houses[c][RentCost]);
					    		SendClientMessage(playerid, COLOR_WHITE, string2);
						    }
						    else
						    {
								format(string, sizeof(string), "[Adress: %d] You're standing on %s's porch",c,Houses[c][Owner]);
						    	SendClientMessage(playerid, COLOR_GREEN, string);
						    	SendClientMessage(playerid, COLOR_WHITE, "Available commands: /enter, /ds(hout)");
					    	}
						}
					}
				}
			}
		}
	}
	return 1;
}
Reply
#6

Can someone help me,please?
Reply
#7

Quote:
Originally Posted by Dominic123
Посмотреть сообщение
Код:
if(checkpointid == Houses[c][PickupID])
Pickups differ from checkpoints.

A more efficient way to do it would be to assign to extra ID by streamer the house index (increased though as 0 is the default) for that checkpoint and retrieve it with Streamer_GetIntData. By that, you won't even need any loop!
Reply
#8

Ok,i don't understood,can you give me an example,please?
Reply
#9

Ignore what I said about the pickups and checkpoints, I just saw that you used that name but it's correct.

PHP код:
// when creating the checkpoint for a house:
Houses[idx][PickupID] = CreateDynamicCP(Houses[idx][EnterX], Houses[idx][EnterY], Houses[idx][EnterZ], 1.4, -1, -1, -11.4);
Streamer_SetIntData(STREAMER_TYPE_CPHouses[idx][PickupID], E_STREAMER_EXTRA_IDMAX_HOUSES idx);
public 
OnPlayerEnterDynamicCP(playeridcheckpointid)
{
    if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        new 
house_index Streamer_GetIntData(STREAMER_TYPE_CPcheckpointE_STREAMER_EXTRA_ID);
        if (
house_index >= MAX_HOUSES)
        {
            
house_index -= MAX_HOUSES;
            if (
Houses[house_index][HousePrice])
            {
                if (!
Houses[house_index][Owned])
                {
                    
SendClientMessage(playeridCOLOR_GREEN"Doresti sa cumperi aceasta proprietate?");
                    new 
string[20];
                    
format(stringsizeof(string), "Price: $%d"Houses[house_index][HousePrice]);
                    
SendClientMessage(playeridCOLOR_GREENstring);
                    
SendClientMessage(playeridCOLOR_WHITE"Available commands: /buyhouse, /enter, /ds(hout)");
                }
                else
                {
                    new 
string[70];
                    if (
Houses[house_index][Rentable])
                    {
                        
format(stringsizeof(string), "[Adress: %d] You're standing on %s's porch."house_indexHouses[house_index][Owner]);
                        
SendClientMessage(playeridCOLOR_GREENstring);
                        
format(stringsizeof(string), "Available commands: /enter, /ds(hout), /rentroom (Price: $%d)"Houses[house_index][RentCost]);
                        
SendClientMessage(playeridCOLOR_WHITEstring);
                    }
                    else
                    {
                        
format(stringsizeof(string), "[Adress: %d] You're standing on %s's porch"house_indexHouses[house_index][Owner]);
                        
SendClientMessage(playeridCOLOR_GREENstring);
                        
SendClientMessage(playeridCOLOR_WHITE"Available commands: /enter, /ds(hout)");
                    }
                }
            }
        }
    }
    return 
1;

Reply
#10

Still don't work
LoadHouse CODE
Код:
forward LoadHouses();
public LoadHouses()
{
    new arrCoords[28][64];
    new sql[80], row[512];
    format(sql, sizeof(sql), "SELECT COUNT(*) FROM Houses");
    mysql_query(sql);
    mysql_store_result();
    mysql_fetch_row(row);
    mysql_free_result();
    for (new idx=0; idx<MAX_HOUSES; idx++)
	{
        format(sql, sizeof(sql), "SELECT * FROM Houses WHERE HouseID=%d", idx);
        mysql_query(sql);
        mysql_store_result();
        if (mysql_num_rows() > 0)
		{
            mysql_fetch_row(row);
            split(row, arrCoords, '|');
            mysql_free_result();
            Houses[idx][EnterX] = floatstr(arrCoords[1]);
            Houses[idx][EnterY] = floatstr(arrCoords[2]);
            Houses[idx][EnterZ] = floatstr(arrCoords[3]);
            Houses[idx][EnterAngle] = floatstr(arrCoords[4]);
            Houses[idx][ExitX] = floatstr(arrCoords[5]);
            Houses[idx][ExitY] = floatstr(arrCoords[6]);
            Houses[idx][ExitZ] = floatstr(arrCoords[7]);
            strmid(Houses[idx][Owner], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            Houses[idx][Owned] = strval(arrCoords[9]);
            Houses[idx][HousePrice] = strval(arrCoords[10]);
            Houses[idx][ExitInterior] = strval(arrCoords[11]);
            Houses[idx][hGun1] = strval(arrCoords[12]);
            Houses[idx][hGunAmmo1] = strval(arrCoords[13]);
            Houses[idx][hGun2] = strval(arrCoords[14]);
            Houses[idx][hGunAmmo2] = strval(arrCoords[15]);
            Houses[idx][hGun3] = strval(arrCoords[16]);
            Houses[idx][hGunAmmo3] = strval(arrCoords[17]);
            Houses[idx][Money] = strval(arrCoords[18]);
            Houses[idx][Rentable] = strval(arrCoords[19]);
            Houses[idx][RentCost] = strval(arrCoords[20]);
            Houses[idx][PickupID] = strval(arrCoords[21]);
            Houses[idx][hFridge] = strval(arrCoords[22]);
            Houses[idx][hBox] = strval(arrCoords[23]);
            Houses[idx][Drugs] = strval(arrCoords[24]);
            Houses[idx][Dynamic] = strval(arrCoords[25]);
            Houses[idx][Materials] = strval(arrCoords[26]);
            Houses[idx][Locked] = strval(arrCoords[27]);
            Houses[idx][PickupID] = CreateDynamicCP(Houses[idx][EnterX], Houses[idx][EnterY], Houses[idx][EnterZ], 1.4, -1, -1, -1, 1.4);
			Streamer_SetIntData(STREAMER_TYPE_CP, Houses[idx][PickupID], E_STREAMER_EXTRA_ID, MAX_HOUSES + idx);
            new string[128];
            if(Houses[idx][Owned] == 0)
			{
                new houselocation[MAX_ZONE_NAME];
                GetCoords2DZone(Houses[idx][EnterX],Houses[idx][EnterY], houselocation, MAX_ZONE_NAME);
                format(string, sizeof(string), "[For Sale]\nAddress: %d %s\nPrice: %d$",idx,houselocation,Houses[idx][HousePrice]);
                housetext2[idx] = Create3DTextLabel(string,COLOR_BLACK,Houses[idx][EnterX],Houses[idx][EnterY],Houses[idx][EnterZ],5.0,0, 0);
                format(string, sizeof(string), "[For Sale]\nAddress: %d %s\nPrice: %d$",idx,houselocation,Houses[idx][HousePrice]);
                housetext[idx] = Create3DTextLabel(string,0xbec339ff,Houses[idx][EnterX],Houses[idx][EnterY],Houses[idx][EnterZ],5.0,0, 0);
            }
        }
    }
    mysql_free_result();
    printf("%d house load from databse", MAX_HOUSES);
    return true;
}
OnPlayerEnterDynamicCP
Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        new house_index = Streamer_GetIntData(STREAMER_TYPE_CP, checkpoint, E_STREAMER_EXTRA_ID);
        if (house_index >= MAX_HOUSES)
        {
            house_index -= MAX_HOUSES;
            if (Houses[house_index][HousePrice])
            {
                if (!Houses[house_index][Owned])
                {
                    SendClientMessage(playerid, COLOR_GREEN, "Do you want to buy this house?");
                    new string[20];
                    format(string, sizeof(string), "Price: $%d", Houses[house_index][HousePrice]);
                    SendClientMessage(playerid, COLOR_GREEN, string);
                    SendClientMessage(playerid, COLOR_WHITE, "Available commands: /buyhouse, /enter, /ds(hout)");
                }
                else
                {
                    new string[70];
                    if (Houses[house_index][Rentable])
                    {
                        format(string, sizeof(string), "[Adress: %d] You're standing on %s's porch.", house_index, Houses[house_index][Owner]);
                        SendClientMessage(playerid, COLOR_GREEN, string);
                        format(string, sizeof(string), "Available commands: /enter, /ds(hout), /rentroom (Price: $%d)", Houses[house_index][RentCost]);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                    }
                    else
                    {
                        format(string, sizeof(string), "[Adress: %d] You're standing on %s's porch", house_index, Houses[house_index][Owner]);
                        SendClientMessage(playerid, COLOR_GREEN, string);
                        SendClientMessage(playerid, COLOR_WHITE, "Available commands: /enter, /ds(hout)");
                    }
                }
            }
        }
    }
    return 1;
}
I think is problem with checkpoint ..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)