Sweeper Job problem zcmd
#1

Hmm, two errors problem:

sweeper.pwn(41) : warning 209: function "cmd_sweeper" should return a value
sweeper.pwn(42) : error 010: invalid function or declaration


Код:
#include <a_samp>
#include <zcmd>
#define COLOR_DARKGOLD 0x808000AA
#define COLOR_RED 0xFF0000AA
#define COLOR_YELLOW 0xFFFF00AA

new SweepingJob[256];

public OnFilterScriptInit()
{
	AddStaticVehicle(574,1424.8956,-1844.7279,13.2739,359.7335,0,0); 
	AddStaticVehicle(574,1428.4050,-1844.6340,13.2739,0.7382,0,0);
	AddStaticVehicle(574,1431.9050,-1844.6138,13.2739,1.4491,0,0); 
}
forward SweeperJobFinish(playerid);
public SweeperJobFinish(playerid)
{
	if(SweepingJob[playerid] == 0){ return 1; }

	GivePlayerMoney(playerid,200);
	SendClientMessage(playerid,COLOR_YELLOW,"* You have been payed for your job! - $200");
	SweepingJob[playerid] = 0;

	return 1;
}

CMD:sweeper(playerid, params[])
{
	if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 574)
	{
 		SweepingJob[playerid] = 1;
   		new name[MAX_PLAYER_NAME], string[48];
   		GetPlayerName(playerid, name, sizeof(name));
     	format(string, sizeof(string), "* %s is now a StreetSweeper.", name );
      	SendClientMessageToAll(COLOR_YELLOW, string);
		SendClientMessage(playerid,COLOR_YELLOW,"* Clean the street for 1 minute and recieve $200");
  		SetTimerEx("SweeperJobFinish", 60000, false, "i", playerid);
		return 1;
   	}
	SendClientMessage(playerid, COLOR_RED,"You have to be in a streetsweeper to start the job");
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
     if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 574)
     {
         SendClientMessage(playerid, COLOR_RED, "* You can start the sweepingjob by using /sweeper");
     }
     return 0;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
	if(SweepingJob[playerid] == 1)
	{
	    SendClientMessage(playerid, COLOR_RED, "* You have left your job, you ain't getting any cash.");
	    SweepingJob[playerid] = 0;
	}
}
Reply
#2

Use thissome lose identations but you can fix it in pawno)

PHP код:
#include <a_samp>
#include <zcmd>
#define COLOR_DARKGOLD 0x808000AA
#define COLOR_RED 0xFF0000AA
#define COLOR_YELLOW 0xFFFF00AA
new SweepingJob[256];
public 
OnFilterScriptInit()
{
    
AddStaticVehicle(574,1424.8956,-1844.7279,13.2739,359.7335,0,0); 
    
AddStaticVehicle(574,1428.4050,-1844.6340,13.2739,0.7382,0,0);
    
AddStaticVehicle(574,1431.9050,-1844.6138,13.2739,1.4491,0,0); 
}
forward SweeperJobFinish(playerid);
public 
SweeperJobFinish(playerid)
{
    if(
SweepingJob[playerid] == 0){ return 1; }
    
GivePlayerMoney(playerid,200);
    
SendClientMessage(playerid,COLOR_YELLOW,"* You have been payed for your job! - $200");
    
SweepingJob[playerid] = 0;
    return 
1;
}
CMD:sweeper(playeridparams[])
{
    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 574)
    {
         
SweepingJob[playerid] = 1;
           new 
name[MAX_PLAYER_NAME], string[48];
           
GetPlayerName(playeridnamesizeof(name));
         
format(stringsizeof(string), "* %s is now a StreetSweeper."name );
          
SendClientMessageToAll(COLOR_YELLOWstring);
        
SendClientMessage(playerid,COLOR_YELLOW,"* Clean the street for 1 minute and recieve $200");
          
SetTimerEx("SweeperJobFinish"60000false"i"playerid);
       }
        else
        {
    
SendClientMessage(playeridCOLOR_RED,"You have to be in a streetsweeper to start the job");
        }    
        return 
1;
}
public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
     if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 574)
     {
         
SendClientMessage(playeridCOLOR_RED"* You can start the sweepingjob by using /sweeper");
     }
     return 
0;
}
public 
OnPlayerExitVehicle(playeridvehicleid)
{
    if(
SweepingJob[playerid] == 1)
    {
        
SendClientMessage(playeridCOLOR_RED"* You have left your job, you ain't getting any cash.");
        
SweepingJob[playerid] = 0;
    }

Reply
#3

Код HTML:
#include <a_samp>
#include <zcmd>

#define FILTERSCRIPT
#define WORKUTILEXITCAR
#define CONTINUEWORKXSECONDSBEFOREEXIT

#define COLOR_DARKGOLD		0x808000AA
#define COLOR_RED		0xFF0000AA
#define COLOR_YELLOW		0xFFFF00AA

#define WORKTIME            2 // Minute(s)
#define WORKPAY             400 // Dolar(s) -> Without $
#define TIMETOGETBACK       5 // Seconds

new bool:Sweeping[MAX_PLAYERS],
			SweepTime[MAX_PLAYERS],
			    Worktimee = WORKTIME,
            TimeToGetBack[MAX_PLAYERS];

forward SweepTimer(playerid);
forward TimeToGetBackInCar(playerid);

public OnFilterScriptInit()
{
	AddStaticVehicle(574, 1424.8956,-1844.7279,13.2739,359.7335 , 12, 6); // Sweep Car
	AddStaticVehicle(574, 1428.4050,-1844.6340,13.2739,0.7382, 12, 6); // Sweep Car
	AddStaticVehicle(574, 1431.9050,-1844.6138,13.2739,1.4491, 12, 6); // Sweep Car
	
	return 1;
}

// ---------------------------------------------------------------------------------------------------------------

CMD:sweeper(playerid, params[])
{
	new VehicleID = GetPlayerVehicleID(playerid),
	    pName[MAX_PLAYER_NAME], String[128], String2[128];
	    
	GetPlayerName(playerid, pName, sizeof(pName));

	format(String, sizeof(String), "* %s(ID:%i) is now a Street Sweeper !", pName, playerid);
	
	if(Worktimee == 1)
		format(String2, sizeof(String2), "* Clean the street for %i minute and recieve $%i", Worktimee, WORKPAY);
		
	else if(Worktimee > 1)
	    format(String2, sizeof(String2), "~h~h~~w~Clean the street for ~b~%i~w~ minutes and recieve ~g$%i", Worktimee, WORKPAY);

	if(Sweeping[playerid] == true)
	    return SendClientMessage(playerid, COLOR_RED, "You can't use this command util work !");
	    
	if(GetVehicleModel(VehicleID) == 574)
	{
		Sweeping[playerid] = true;

		SendClientMessageToAll(COLOR_YELLOW, String);
		GameTextForPlayer(playerid, String2, 5000, 1);
		
		SweepTime[playerid] = Worktimee*60;
  		SetTimer("SweepTimer", 1000, true);
  		
  		return 1;
   	}
   	else SendClientMessage(playerid, COLOR_RED,"You have to be in a streetsweeper to start the work !");
   	
   	return 1;
}

public SweepTimer(playerid)
{
	SweepTime[playerid] --;
	
	if(SweepTime[playerid] <= 0)
	{
	    new String[128], String2[128];
		format(String, sizeof(String), "You have been paid with {008000}$%i{FFFFFF} for your work !", WORKPAY);
		
	    GivePlayerMoney(playerid, WORKPAY);
	    SendClientMessage(playerid, COLOR_DARKGOLD, String);
	    
	    Sweeping[playerid] = false;
	    
 #if defined WORKUTILEXITCAR
 
		if(Worktimee == 1)
			format(String2, sizeof(String2), "* Clean the street for %i minute and recieve $%i", Worktimee, WORKPAY);

		else if(Worktimee > 1)
  			format(String2, sizeof(String2), "~h~h~~w~Clean the street for ~b~%i~w~ minutes and recieve ~g$%i", Worktimee, WORKPAY);
  			
		SweepTime[playerid] = Worktimee*60;
		
		Sweeping[playerid] = true;
 #endif
		
		return 1;
  	}
  	
  	return 1;
}

public TimeToGetBackInCar(playerid)
{
	TimeToGetBack[playerid] --;
	
	if(TimeToGetBack[playerid] == 0)
	{
	    Sweeping[playerid] = false;
	    SendClientMessage(playerid, COLOR_RED, "* You have left your job, you ain't getting any cash !");
	    
	    return 1;
 	}
 	
 	return 1;
}


// ---------------------------------------------------------------------------------------------------------------

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	new VehicleID = GetPlayerVehicleID(playerid);

	if(GetVehicleModel(VehicleID) == 574)
   		return SendClientMessage(playerid, COLOR_YELLOW, "* You can start the sweeping by typing /sweeper !");
   		
	return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
	if(Sweeping[playerid] == true)
	{
	    SendClientMessage(playerid, COLOR_RED, "* You have left your job, you ain't getting any cash !");
 #if defined CONTINUEWORKXSECONDSBEFOREEXIT
	    TimeToGetBack[playerid] = TIMETOGETBACK;
	    SetTimer("TimeToGetBackInCar", 1000, 1);
 #else
 
        Sweeping[playerid] = false;
 #endif
        
        return 1;
	}
	
	return 1;
}
Don't tested it , but i think it's fine ... I put some defines for time , you can switch time from there , and sorry for my bad english

Код HTML:
#define WORKUTILEXITCAR
#define CONTINUEWORKXSECONDSBEFOREEXIT
if u dont want to work again before he worked 1 minute put "//" in face of #define WORKUTILEXITCAR
if u dont want to have a timer when you exit a car before job is leaved put "//" in face of #define CONTINUEWORKXSECONDSBEFOREEXIT

Like that:

Код HTML:
//#define WORKUTILEXITCAR
//#define CONTINUEWORKXSECONDSBEFOREEXIT
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)