Engine
#1

Hello ! I cant make my engine system work properly.

This is what I have under OnPlayerStateChange

Код:
		for(new vID = 1; vID < MAX_Cars; vID++)
        {
			if(!strcmp(TakeRoleplayName(playerid), Autos[vID][aOwner], true))
			{
				runnable[playerid]= 1;
				SendClientMessage(playerid, -1, ""#HALL"You have entered to your car.");
				return 1;
			}
		}
I have this with mysql, and whenever I enter to any car, even if Autos[vID][aOwner] is different from player name, it let's me run the engine.

I hope you can understand me
Reply
#2

well,it's because you are using i,i means all of the cars,lets say i entered a car,it searches in all of the cars,if any car is mine from the max cars it sends the message,you should change it to:
pawn Код:
if(!strcmp(TakeRoleplayName(playerid), Autos[GetPlayerVehicleID(playerid)][aOwner], true))
{
    runnable[playerid]= 1;
    SendClientMessage(playerid, -1, ""#HALL"You have entered to your car.");
    return 1;
}
try it
Reply
#3

Wont work :S
I dont think that this has to do anything with loading either.

Код:
stock LoadCars()
{
	new query[400];
	for(new id = 1; id < MAX_CARS; id++)
	{
	    format(query, sizeof(query), "SELECT * FROM cars WHERE AID = %d", id);
	    mysql_query(query);
	    mysql_store_result();
	    if(mysql_num_rows())
	    if(mysql_fetch_row_format(query,"|"))
        {
            sscanf(query, "p<|>iiis[32]is[32]iiffffiiii",
			Autos[id][aAutoID],Autos[id][aAutoV6ti],Autos[id][iID],
			Autos[id][aOwner],Autos[id][aMudel],Autos[id][AutoNimi],
			Autos[id][aHind],Autos[id][aKiirus], Autos[id][aPosx],
			Autos[id][aPosy],Autos[id][aPosz],
			Autos[id][aAngle],Autos[id][vAku],
			Autos[id][vKytus],Autos[id][vVarv1],Autos[id][vVarv2]);

            Total_Cars_Created++;
            printf("Car: %d Owner: %s AutoID: %d ss %d", Autos[id][aAutoID],Autos[id][aOmanik],Autos[id][iID], Autos[id][aAutoV6ti]);
			AddStaticVehicleEx(Autos[id][aMudel], Autos[id][aPosx], Autos[id][aPosy], Autos[id][aPosz], Autos[id][aAngle],Autos[id][vVarv1],Autos[id][vVarv2], -1);
        }
	}
	printf("> %d cars loaded from database.", Total_Cars_Created);
	return 1;
}
printf tells eveything and cars load into game properly I have tried to do this engine multible ways, but my head no longer works
Maybe you have any other code/idea ?
Reply
#4

BUMP

Also here's engine cmd

Код:
CMD:engine(playerid, params[])
{
	new pName[MAX_PLAYER_NAME];GetPlayerName(playerid,pName,sizeof pName);
	new veh = GetPlayerVehicleID(playerid);
	if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid, -1,POLE_AUTOS);
	if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)return SendClientMessage(playerid, -1, PEAD_OLEMA_JUHT);
	new engine,lights,alarm,doors,bonnet,boot,objective;
	veh = GetPlayerVehicleID(playerid);
	GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
	if(engine == 0 ||engine == -1)
	{
		if(runnable[playerid] == 0) return SendClientMessage(playerid, -1, ""VIGA" You cant use this machine!");
		SetVehicleParamsEx(veh,1,lights,alarm,doors,bonnet,boot,objective);
		format(stri, sizeof(stri), "* %s runs engine", V6taRoleplayNimi(playerid), params);
		KeegiL2hedal(playerid, -1, stri);
		Autos[veh][vEngine] = 1;
		Autos[veh][vAku] -= 3;
		return 1;
	}
	else
	{
		SetVehicleParamsEx(veh,0,lights,alarm,doors,bonnet,boot,objective);
		format(stri, sizeof(stri), "* %s turns engine off", V6taRoleplayNimi(playerid), params);
		KeegiL2hedal(playerid, -1, stri);
		Autos[veh][vEngine] = 0;
	}
	return 1;
}
Reply
#5

bump
Reply
#6

bringupmypost.
anyone?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)