[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
#2

To be honest, this isn't tutorial. Tutorials are made to explain to people, what every function and and others things do. However, there are a lot of undefined words.
pawn Code:
new l1staff[MAX_PLAYERS], l2staff[MAX_PLAYERS], l2staff[MAX_PLAYERS], l4staff [MAX_PLAYERS], prstaff[MAX_PLAYERS], newbstaff[MAX_PLAYERS];
Reply
#3

I said at first, thats your admin check. Use your function... IsPlayerAdmin is default rcon I think
Reply
#4

Okay, but with this code, people might confused. I suggest you to replace it with this. it's more easy
pawn Code:
if(!IsPlayerAdmin(playrid)) return SendClientMessage(playerid, COLOR_RED, "(SS-INFO) Access denied!");
Reply
#5

I fixed it up, you might want to copy and replace my code.
Reply
#6

Wow not heard of an enum have you? All mine are PlayerInfo[playerid][pAdmin] >= level etc... Sorry to say but what a waste of time a space and makes the script look crap however nice enough tutorial for the newbies
Reply
#7

I scripted the gamemode when I first started scripting, I've never been bothered to make a enum for it.
Reply
#8

Yes tutorial for newbies.
Reply
#9

Nice tutorial but why use strcmp? There is much easier things out there now like ZCMD
Reply
#10

Not very good because this code will respawn all cars, also if there are driver in the car. You must add a condition to respawn all cars who are not use!

Bye!
Reply
#11

Can anybody help me with these errors?
Respawnvehicles.pwn(95) : error 028: invalid subscript (not an array or too many subscripts): "IsPlayerAdmin"
Respawnvehicles.pwn(95) : warning 215: expression has no effect
Respawnvehicles.pwn(95) : error 001: expected token: ";", but found "]"
Respawnvehicles.pwn(95) : error 029: invalid expression, assumed zero
Respawnvehicles.pwn(95) : fatal error 107: too many error messages on one line
Reply
#12

show me YOUR line 95
Reply
#13

Bad tutorial.
Reply
#14

You wrote:
pawn Code:
for(new c=0;c<MAX_VEHICLES;c++)
{
    RespawnVehicle(c);
}
It should be:
pawn Code:
for(new c=0;c<MAX_VEHICLES;c++)
{
    SetVehicleToRespawn(c);
}
Reply
#15

nice tuto
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)