OnPlayerStateChange broken
#1

Well, this is the code:
Код:
for(new i = 0; i < MAX_PVEHICLES; i++)
    {
	    if(VehicleInfo[i][vType] == 2)
		{
			if(newstate == PLAYER_STATE_DRIVER)
			{
 				SendClientMessage(playerid, -1, "| This is a Spawn Vehicle | Respawn time: 200 seconds |");
			}
		}
		if(VehicleInfo[i][vType] == 1)
		{
			if(newstate == PLAYER_STATE_DRIVER)
			{
			    if(!strcmp(VehicleInfo[i][vOwner],"Noone", true))
			    {
		    		SendClientMessage(playerid, -1, "| This vehicle is owned by x |");
				}
				else
				{
				    SendClientMessage(playerid, -1, "| This vehicle is for sale |");
				}
			}
		}
	}
No matter what car I enter, I get this message once:
Код:
SendClientMessage(playerid, -1, "| This is a Spawn Vehicle | Respawn time: 200 seconds |");
And this message twice:
Код:
SendClientMessage(playerid, -1, "| This vehicle is owned by x |");
And I still don't know why because I used this:
Код:
if(VehicleInfo[i][vType] == 2)
and
Код:
if(VehicleInfo[i][vType] == 1)

Here is how I load vType:
Код:
stock LoadVehicleStats()
{

    new DB_Query[1024];

    for(new i = 0; i < MAX_PVEHICLES; i++)
	{
	    mysql_format(Database, DB_Query, sizeof(DB_Query), "SELECT * FROM `Vehicles` WHERE `ID` = '%d'", i);
     	mysql_query(Database, DB_Query);
		
    	cache_get_value_int(0, "ID", VehicleInfo[i][ID]);

		cache_get_value(0, "Owner", VehicleInfo[i][vOwner]);
		cache_get_value_int(0, "vModel", VehicleInfo[i][vModel]);

		cache_get_value_float(0, "Pos_x", VehicleInfo[i][vPos_x]);
		cache_get_value_float(0, "Pos_y", VehicleInfo[i][vPos_y]);
		cache_get_value_float(0, "Pos_z", VehicleInfo[i][vPos_z]);
		cache_get_value_float(0, "Rot", VehicleInfo[i][vRot]);
		
		cache_get_value_int(0, "Fuel", VehicleInfo[i][vFuel]);
		cache_get_value_int(0, "Type", VehicleInfo[i][vType]);
		cache_get_value(0, "Plate", VehicleInfo[i][vPlate]);
		cache_get_value_int(0, "vLock", VehicleInfo[i][vLock]);

		cache_get_value_int(0, "Color1", VehicleInfo[i][vColor1]);
		cache_get_value_int(0, "Color2", VehicleInfo[i][vColor2]);
		cache_get_value_int(0, "RespawnDelay", VehicleInfo[i][vRespawnDelay]);
		cache_get_value_int(0, "Price", VehicleInfo[i][vPrice]);
		VehicleInfo[i][Vehicle_Cache] = cache_save();
	
		pvehicle[VehicleInfo[i][ID]] = CreateVehicle(VehicleInfo[i][vModel], VehicleInfo[i][vPos_x], VehicleInfo[i][vPos_y], VehicleInfo[i][vPos_z], VehicleInfo[i][vRot], VehicleInfo[i][vColor1], VehicleInfo[i][vColor2], VehicleInfo[i][vRespawnDelay]);
	}
	return 1;
}
Reply
#2

Bump
Reply
#3

You're being worse than MerryDeer.
Reply
#4

Use break in loop when you find the match.
Reply
#5

Quote:
Originally Posted by oMa37
Посмотреть сообщение
You're being worse than MerryDeer.
Rules:
Код:
No Spam - If you are adding no useful information to a topic, you are spamming. This includes memes of any sort, especially in the more serious areas of the forum.
How does your comment help me in any way? If you don't want to help me or if my posts bother you then please ignore them.
Reply
#6

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
Rules:
Код:
No Spam - If you are adding no useful information to a topic, you are spamming. This includes memes of any sort, especially in the more serious areas of the forum.
How does your comment help me in any way? If you don't want to help me or if my posts bother you then please ignore them.
Quote:

Use break in loop when you find the match.

Can you show me an example? Couldn't find one in the wiki.



#Ouch, sorry for double post, I used my tabled and I clicked on quote instead of edit...
Reply
#7

Why are you iterating through all vehicles when you could just do a GetPlayerVehicleID? I cant understand your logic.
Reply
#8

Quote:
Originally Posted by Spmn
Посмотреть сообщение
Why are you iterating through all vehicles when you could just do a GetPlayerVehicleID? I cant understand your logic.
Yea.. I figured that few minutes ago, forgot about this post, I am not sure how I could forget about that..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)