A bad bug... -
Rokzlive - 13.12.2010
Ok, i use bills truckingmissions include, and theres a bug. When a player types /work, it gives them a mission, but they can keep typeing it and it will keep giving them a new mission. I want it so that if a player already has a mission, it will instead of giving them a new one it says "You are already working!"
Heres my /work command
pawn Код:
if(!strcmp("/work", cmdtext, true))
{
new pvehiclemodel = GetVehicleModel(GetPlayerVehicleID(playerid));
if (pvehiclemodel == 403 || pvehiclemodel == 514 || pvehiclemodel == 515) {
new string[100];
new rand = random(sizeof(TruckMissionRandom));
CreatePlayerMission(playerid, TruckMissionRandom[rand][UseTrailerCheck], TruckMissionRandom[rand][MissionPay], TruckMissionRandom[rand][loadx],TruckMissionRandom[rand][loady], TruckMissionRandom[rand][loadz], TruckMissionRandom[rand][unloadx],TruckMissionRandom[rand][unloady], TruckMissionRandom[rand][unloadz]);
format(string, sizeof(string), "%s", TruckMissionRandom[rand][MissionName]);
SendClientMessage(playerid, 0x00FF00FF, string);
MissionArrayID[playerid] = rand;
TextDrawHideForPlayer(playerid, mission[playerid]);
TextDrawShowForPlayer ( playerid, mission [ playerid ] );
TextDrawSetString(mission [ playerid ],string);
}
else
{
}
return 1;
}
And whit my stopwork command, if you say stopwork it will cancel the mission and charge you, but it you keep saying it it will keep charging you. I want it so that if they are not on a mission it like nulls the command and says "You are not working!"
Heres my stopwork command
pawn Код:
if(!strcmp("/stopwork", cmdtext, true))
{
if(IsPlayerConnected(playerid))
{
CancelPlayersCurrentMission(playerid);
new string[100];
format(string, sizeof(string),"To start a mission type /work");
TextDrawShowForPlayer ( playerid, mission [ playerid ] );
TextDrawSetString(mission [ playerid ],string);
}
return 1;
}
Re: A bad bug... -
Rokzlive - 13.12.2010
Anyone help?
Respuesta: A bad bug... -
Quantum - 13.12.2010
You can make a variable for that, for example, at the top of your script:
pawn Код:
new isworking[MAX_PLAYERS];
Add this to set it to 0 under OnPlayerConnect and OnPlayerDisconnect:
You may want to add it under OnPlayerDeath or OnPlayerSpawn too.
Here are the commands:
pawn Код:
if(!strcmp("/work", cmdtext, true))
{
if(isworking[playerid] == 1) return SendClientMessage(playerid, COLOR, "You are already working!");
isworking[playerid] = 1;
new pvehiclemodel = GetVehicleModel(GetPlayerVehicleID(playerid));
if (pvehiclemodel == 403 || pvehiclemodel == 514 || pvehiclemodel == 515) {
new string[100];
new rand = random(sizeof(TruckMissionRandom));
CreatePlayerMission(playerid, TruckMissionRandom[rand][UseTrailerCheck], TruckMissionRandom[rand][MissionPay], TruckMissionRandom[rand][loadx],TruckMissionRandom[rand][loady], TruckMissionRandom[rand][loadz], TruckMissionRandom[rand][unloadx],TruckMissionRandom[rand][unloady], TruckMissionRandom[rand][unloadz]);
format(string, sizeof(string), "%s", TruckMissionRandom[rand][MissionName]);
SendClientMessage(playerid, 0x00FF00FF, string);
MissionArrayID[playerid] = rand;
TextDrawHideForPlayer(playerid, mission[playerid]);
TextDrawShowForPlayer ( playerid, mission [ playerid ] );
TextDrawSetString(mission [ playerid ],string);
}
else
{
}
return 1;
}
if(!strcmp("/stopwork", cmdtext, true))
{
if(IsPlayerConnected(playerid))
{
if(isworking[playerid] == 0) return SendClientMessage(playerid, COLOR, "You are not working!");
isworking[playerid] = 0;
CancelPlayersCurrentMission(playerid);
new string[100];
format(string, sizeof(string),"To start a mission type /work");
TextDrawShowForPlayer ( playerid, mission [ playerid ] );
TextDrawSetString(mission [ playerid ],string);
}
return 1;
}
Re: A bad bug... -
VirSpectorX - 13.12.2010
Or the other way, is using
SetPVarInt. That's the easiest way.
So, it's gonna be like this
pawn Код:
if(!strcmp("/work", cmdtext, true))
{
new pvehiclemodel = GetVehicleModel(GetPlayerVehicleID(playerid));
if (pvehiclemodel == 403 || pvehiclemodel == 514 || pvehiclemodel == 515) {
new string[100];
new rand = random(sizeof(TruckMissionRandom));
if(GetPVarInt(playerid, "work") == 1)
{
return SendClientMessage(playerid, 0x00FF00FF, "You are already working");
}
CreatePlayerMission(playerid, TruckMissionRandom[rand][UseTrailerCheck], TruckMissionRandom[rand][MissionPay], TruckMissionRandom[rand][loadx],TruckMissionRandom[rand][loady], TruckMissionRandom[rand][loadz], TruckMissionRandom[rand][unloadx],TruckMissionRandom[rand][unloady], TruckMissionRandom[rand][unloadz]);
SetPVarInt(playerid, "work", 1);
format(string, sizeof(string), "%s", TruckMissionRandom[rand][MissionName]);
SendClientMessage(playerid, 0x00FF00FF, string);
MissionArrayID[playerid] = rand;
TextDrawHideForPlayer(playerid, mission[playerid]);
TextDrawShowForPlayer ( playerid, mission [ playerid ] );
TextDrawSetString(mission [ playerid ],string);
}
else
{
}
return 1;
}
if(!strcmp("/stopwork", cmdtext, true))
{
if(IsPlayerConnected(playerid))
{
if(GetPVarInt(playerid, "work") == 0)
{
return SendClientMessage(playerid, 0x00FF00FF, "You are not working");
}
CancelPlayersCurrentMission(playerid);
SetPVarInt(playerid, "work", 0);
new string[100];
format(string, sizeof(string),"To start a mission type /work");
TextDrawShowForPlayer ( playerid, mission [ playerid ] );
TextDrawSetString(mission [ playerid ],string);
}
return 1;
}
So, you'll need to add the line below in
OnPlayerDisconnect part.
pawn Код:
SetPVarInt(playerid, "work", 0);
Good luck!
Quote:
Quantum is right. I didn't see that OnPlayerDisconnect stuff. Sorry!
|
Re: A bad bug... -
Rokzlive - 13.12.2010
WOOT THANKYOU!