17.08.2011, 12:07
Okay, I am trying to make 0.3c engine system for my server, but it only works for ID 0, I meant it's bugged for players with other IDs. Example: If player ID 1 attempts to start the engine it turns the engine of vehicle for player id 0. Only player id 0 can turn his engine, other can't.
Pastebin: http://pastebin.com/FKxffhbs
If you know where is the problem, tell me how to fix it, pls
pawn Код:
forward EngineTimer(playerid);
forward EngineTimer2(playerid);
forward EngineTimer3(playerid);
forward EngineTimer4(playerid);
if(strcmp(cmd, "/start", true) == 0)//start
{
if(IsPlayerConnected(playerid))
{
if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && (PlayerFrozen[playerid] == 0) && (PlayerInfo[playerid][pLocked] == 0))
{
if(Impounded[GetPlayerVehicleID(playerid)])return SendClientMessage(playerid,COLOR_WHITE,"Vehicle has been booted and cannot move!");
GetPlayerName(playerid, sendername, sizeof(sendername));
ApplyAnimation(playerid,"CAR_CHAT","carfone_out",4.1,0,1,1,1,1);
format(string, sizeof(string), " %s rips off the ignition cover", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetTimer("EngineTimer",1000, false);
SetTimer("EngineTimer2",2000, false);
SetTimer("EngineTimer3",2500, false);
printf("%s", string);
//EnterCarTime[playerid] += 1;
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not in a Vehicle!");
return 1;
}
}
}
if(strcmp(cmd,"/stop", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0, lights, alarm, doors, bonnet, boot, objective);
//SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, 0, alarm, doors, bonnet, boot, objective);
GetPlayerName(playerid,sendername,sizeof(sendername));
format(string, sizeof(string), "** %s turns their engine OFF.",sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SetTimer("EngineTimer4",500,false);
//TogglePlayerControllable(playerid, 0);
//CarRunning[VID] = 0;
//}
//else
//{
// SendClientMessage(playerid, COLOR_GREY, "Your vehicle is already off or engine is not running.");
//return 1;
//}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not in a vehicle !");
return 1;
}
}
}
public EngineTimer4(playerid)
{
if(IsPlayerConnected(playerid))
{
if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && (PlayerFrozen[playerid] == 0) && (PlayerInfo[playerid][pLocked] == 0))
{
new string[256];
new sendername[MAX_PLAYER_NAME];
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, 0, alarm, doors, bonnet, boot, objective);
GetPlayerName(playerid,sendername,sizeof(sendername));
format(string, sizeof(string), "** Engine is NOT running (( %s )).",sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not in a Vehicle!");
return 1;
}
}
return 1;
}
public EngineTimer3(playerid)
{
if(IsPlayerConnected(playerid))
{
if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && (PlayerFrozen[playerid] == 0) && (PlayerInfo[playerid][pLocked] == 0))
{
new string[256];
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), " Engine is running (( %s ))", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not in a Vehicle!");
return 1;
}
}
return 1;
}
public EngineTimer2(playerid)
{
if(IsPlayerConnected(playerid))
{
if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && (PlayerFrozen[playerid] == 0) && (PlayerInfo[playerid][pLocked] == 0))
{
new string[256];
new sendername[MAX_PLAYER_NAME];
new engine, lights, alarm, doors, bonnet, boot, objective;
GetPlayerName(playerid, sendername, sizeof(sendername));
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, lights, alarm, doors, bonnet, boot, objective);
//SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, 1, alarm, doors, bonnet, boot, objective);
format(string, sizeof(string), " Successfully turns their engine ON (( %s ))", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not in a Vehicle!");
return 1;
}
}
return 1;
}
public EngineTimer(playerid)
{
if(IsPlayerConnected(playerid))
{
if((GetPlayerState(playerid) == PLAYER_STATE_DRIVER) && (PlayerFrozen[playerid] == 0) && (PlayerInfo[playerid][pLocked] == 0))
{
new string[256];
new sendername[MAX_PLAYER_NAME];
new engine, lights, alarm, doors, bonnet, boot, objective;
ApplyAnimation(playerid,"CAR_CHAT","carfone_out",4.1,0,1,1,1,1);
//GetPlayerName(playerid, sendername, sizeof(sendername));
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, 1, alarm, doors, bonnet, boot, objective);
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), " %s touches the ignition wires together and attempts to start the vehicle", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You are not in a Vehicle!");
return 1;
}
}
return 1;
}
If you know where is the problem, tell me how to fix it, pls