SA-MP Forums Archive
[Tutorial] How to make a "/respawnvehicles" command! (strcmp) - 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)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to make a "/respawnvehicles" command! (strcmp) (/showthread.php?tid=308226)



How to make a "/respawnvehicles" command! (strcmp) - vincee - 02.01.2012

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;
        }
    }



Re: How to make a "/respawnvehicles" command! (strcmp) - Konstantinos - 02.01.2012

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];



Re: How to make a "/respawnvehicles" command! (strcmp) - vincee - 02.01.2012

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


Re: How to make a "/respawnvehicles" command! (strcmp) - Konstantinos - 02.01.2012

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!");



Re: How to make a "/respawnvehicles" command! (strcmp) - vincee - 02.01.2012

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


Re: How to make a "/respawnvehicles" command! (strcmp) - DarkKillerWithPride<3 - 02.01.2012

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


Re: How to make a "/respawnvehicles" command! (strcmp) - vincee - 02.01.2012

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


Re: How to make a "/respawnvehicles" command! (strcmp) - Littlehelper - 03.01.2012

Yes tutorial for newbies.


Re: How to make a "/respawnvehicles" command! (strcmp) - LiamM - 03.01.2012

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


Re : How to make a "/respawnvehicles" command! (strcmp) - mehdi-jumper - 03.01.2012

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!


Re: How to make a "/respawnvehicles" command! (strcmp) - Marin_Franolic - 03.01.2012

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


Re: How to make a "/respawnvehicles" command! (strcmp) - vincee - 05.01.2012

show me YOUR line 95


Re: How to make a "/respawnvehicles" command! (strcmp) - Max_Coldheart - 05.01.2012

Bad tutorial.


Re: How to make a "/respawnvehicles" command! (strcmp) - Rob_Maate - 07.01.2012

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);
}



Re: How to make a "/respawnvehicles" command! (strcmp) - Scripter123 - 07.01.2012

nice tuto