HELP, only one person can work
#1

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    GetPlayerName(playerid,name2,MAX_PLAYER_NAME);
	if (strcmp("/work", cmdtext, true, 10) == 0)
	{
		new rand = random(sizeof(truckcheckpoints));
        if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))){ SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!"); return 1; }
		if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 515 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 514 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 403)
        {
	    if(injob == 0)
	    {
	    SendClientMessage(playerid,COLOR_RED2,"You can leave it using /leave!");
	    format(string1,sizeof string1,"%s is now a SA Trucker!",name2);
	    SendClientMessageToAll(COLOR_PINK,string1);
	    injob = 1;
        courier1[playerid] = 1;
        {
		SetPlayerCheckpoint(playerid,truckcheckpoints[rand][0],truckcheckpoints[rand][1],truckcheckpoints[rand][2],3);
		SetPlayerMapIcon(playerid,1,truckcheckpoints[rand][0],truckcheckpoints[rand][1],truckcheckpoints[rand][2],0,MAPICON_GLOBAL_CHECKPOINT);
		}
		return 1;
	    }
		if(injob == 1)
		{
		return SendClientMessage(playerid,COLOR_RED2,"You are already in a Job!");
		}
		}else SendClientMessage(playerid,COLOR_RED2,"You must be in a Burrito or Faggio to start this job!");
		return 1;
	}
	if (strcmp("/leave", cmdtext, true, 10) == 0)
	{
	    if(injob == 1)
	    {
	    format(string1,sizeof string1,"%s is now a SA Citizen!",name2);
	    SendClientMessageToAll(COLOR_RED,string1);
	    injob = 0;
		DisablePlayerCheckpoint(playerid);
		RemovePlayerMapIcon(playerid,1);
		courier1[playerid] = 0;
     	KillTimer(_Time);
		return 1;
		}
		if(injob == 0){
	 	SendClientMessage(playerid,COLOR_RED2,"You are already not working!");
	 	return 1;
		}
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid) == 515 || GetVehicleModel(vehicleid) == 514 || GetVehicleModel(vehicleid) == 403)
    {
		SendClientMessage(playerid, COLOR_ORANGE, "*You can start the Trucker Job by using /work !");
	}
	return 0;
}

forward UnfreezePlayer(playerid);
public UnfreezePlayer(playerid)
{
	TogglePlayerControllable(playerid, 1);
}

public OnPlayerEnterCheckpoint(playerid)
{
    //-------------courier--------------
    {
    if(!IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))){ SendClientMessage(playerid,COLOR_RED,"* You don't have a trailer attached to the vehicle!"); return 1; }
	TogglePlayerControllable(playerid, 0);
	SetTimerEx("UnfreezePlayer", 3000, false, "d", playerid);

	new rand = random(sizeof(truckcheckpoints));
    if(courier1[playerid] > 0 && courier1[playerid] < 5)
	{
	GivePlayerMoney(playerid,20000);
	SendClientMessage(playerid,COLOR_GREEN,"You got $20000 for successfully delivered the goods!");
    courier1[playerid]++;
    RemovePlayerMapIcon(playerid,1);
    {
    SetPlayerCheckpoint(playerid,truckcheckpoints[rand][0],truckcheckpoints[rand][1],truckcheckpoints[rand][2],3);
    SetPlayerMapIcon(playerid,1,truckcheckpoints[rand][0],truckcheckpoints[rand][1],truckcheckpoints[rand][2],0,MAPICON_GLOBAL_CHECKPOINT);
	}
	}
	else if(courier1[playerid] == 5)
	{
	GivePlayerMoney(playerid,20000);
	SendClientMessage(playerid,COLOR_GREEN,"You delivered the goods safely and earned yourself $20000!");
	SendClientMessage(playerid,COLOR_LIGHTBLUE,"You Finished your job! Got:(10000$)");
    RemovePlayerMapIcon(playerid,1);
    DisablePlayerCheckpoint(playerid);
    injob = 0;
    courier1[playerid] = 0;
	}
	}
	return 1;
}
Reply
#2

You forgot to add MAX_PLAYERS for the 'injob' variable.

new injob[MAX_PLAYERS];

use injob[playerid] in the code for future references.
Reply
#3

lol you got me on msn :S
when u get online i'll help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)