SA-MP Forums Archive
Respawn all cars Command with dcmd - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Respawn all cars Command with dcmd (/showthread.php?tid=537217)



Respawn all cars Command with dcmd - bobsona - 14.09.2014

Hello, I'm using dcmd and I want to create a command that respawns all unused cars in the server, like this one:
Код:
if(strcmp(cmd, "/respawnallcars", true) == 0) {
            new bool:vehicleused[MAX_VEHICLES];
            for(new i=0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
                {
                    vehicleused[GetPlayerVehicleID(i)] = true;
                }
            }
            for(new i=1; i < MAX_VEHICLES; i++)
            {
                if(!vehicleused[i])
                {
                    SetVehicleToRespawn(i);
                }
            }
            SendClientMessage(playerid, 0x32CD32, "balba!");
            SendClientMessageToAll(0x32CD32, "sth!");
        return 1;
        }
can someone transform it for dcmd for me?

Is that correct? :
Код:
dcmd_respawnallcars(playerid,params[])
	{
	#pragma unused params
	new bool:vehicleused[MAX_VEHICLES];
            for(new i=0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
                {
                    vehicleused[GetPlayerVehicleID(i)] = true;
                }
            }
            for(new i=1; i < MAX_VEHICLES; i++)
            {
                if(!vehicleused[i])
                {
                    SetVehicleToRespawn(i);
                }
            }
            SendClientMessage(playerid, 0x32CD32, "balba!");
            SendClientMessageToAll(0x32CD32, "sth!");
	return 1;
	}



Re: Respawn all cars Command with dcmd - Thogy - 14.09.2014

pawn Код:
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(respawnallcars, 14, cmdtext);
    return 0;
}

dcmd_respawnallcars(playerid, params[])
{
           #pragma unused params
           new bool:vehicleused[MAX_VEHICLES];
            for(new i=0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
                {
                    vehicleused[GetPlayerVehicleID(i)] = true;
                }
            }
            for(new i=1; i < MAX_VEHICLES; i++)
            {
                if(!vehicleused[i])
                {
                    SetVehicleToRespawn(i);
                }
            }
            SendClientMessage(playerid, 0x32CD32, "balba!");
            SendClientMessageToAll(0x32CD32, "sth!");
            return 1;
}



Re: Respawn all cars Command with dcmd - bobsona - 14.09.2014

Thanks very much!