[Tutorial] How to make a "/respawnvehicles" command! (strcmp)
#1

People were unsure on how to make a simple respawn vehicles command!

So here it is

pawn Code:
#include <a_samp>
#define COLOR_RED 0xFF0000
#define COLOR_WHITE 0xFFFFFF
#define COLOR_GREY 0xAFAFAFAA
First you need to ensure you have a admin check.

Second, you want the command line under "OnPlayerCommandText"

so add
pawn Code:
if(strcmp("/respawnvehicles", cmdtext, true) == 0)
// which is your command

Press the "Enter key" then put a bracket
pawn Code:
{
Press the enter key again and press TAB.

Then add your admin check, in my case every level of staff is allowed to respawn vehicles.
[pawn]if(!IsPlayerAdmin[playerid])

Press Enter, then do a
pawn Code:
{
then press enter again and press TAB

and add this line
pawn Code:
for(new c=0;c<MAX_VEHICLES;c++)
// selects every vehicle that is ingame vehicleid is defined as "c"

{
then tab
pawn Code:
RespawnVehicle(c);
return 1;
which actually respawns the vehicles
closing bracket }
then you want it to send a message to all players to inform them.

Press enter and add

pawn Code:
SendClientMessageToAll(COLOR_WHITE, "----------------------------------------------------------------------------");
            SendClientMessageToAll(COLOR_GREY, "(SS-INFO) Mass car respawn!");
            SendClientMessageToAll(COLOR_WHITE, "----------------------------------------------------------------------------");
return 1;
then add 2 closing brackets.


you should have this
pawn Code:
if(strcmp("/respawnvehicles", cmdtext, true) == 0)
    {
        if(!IsPlayerAdmin[playerid]) // rcon admin
        {
            for(new c=0;c<MAX_VEHICLES;c++)
            {
                RespawnVehicle(c);
            }
            SendClientMessageToAll(COLOR_WHITE, "----------------------------------------------------------------------------");
            SendClientMessageToAll(COLOR_GREY, "(SS-INFO) Mass car respawn!");
            SendClientMessageToAll(COLOR_WHITE, "----------------------------------------------------------------------------");
            return 1;
        }
    }
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)