Dont respawn ingamecreated cars
#1

Hi,

I already asked this a few days ago but noone answered...

So i have a command for spawning some vehicles and a command for respawn all my vehicles but when i use the respawn command the ingamecreated vehicles (/spawn) respawn too.
But i only want to respawn the cars that are Static.

Please help.

CODE:

pawn Код:
CMD:spawn(playerid, params[])
{
    if (IsPlayerAdmin(playerid) || Player[playerid][ALevel] >= 1)
    {
        new Float:x;
        new Float:y;
        new Float:z;
        new Float:a;
       
        if (sscanf(params, "s", params[0]))
        {
            SendClientMessage(playerid, RED, "USAGE: /spawn [object]");
        }
        else if (!strcmp(params[0], gObjects[0], true))
        {
            GetPlayerPos(playerid, x, y, z);
            GetPlayerFacingAngle(playerid, a);
           
            CreateVehicle(522, x-3, y, z+5, a, 0, 0, -1);
        }
        else if (!strcmp(params[0], gObjects[1], true))
        {
            GetPlayerPos(playerid, x, y, z);
            GetPlayerFacingAngle(playerid, a);
           
            CreateVehicle(451, x-3, y, z+5, a, 0, 0, -1);
        }
        else if (!strcmp(params[0], gObjects[2], true))
        {
            GetPlayerPos(playerid, x, y, z);
            GetPlayerFacingAngle(playerid, a);
           
            CreateVehicle(425, x-5, y, z+5, a, 0, 0, -1);
        }
        else if (!strcmp(params, gObjects[3], true))
        {
            GetPlayerPos(playerid, x, y, z);
            GetPlayerFacingAngle(playerid, a);
           
            CreateVehicle(520, x-3, y, z+5, a, 0, 0, -1);
        }
        else
        {
            SendClientMessage(playerid, RED, "SERVER: Fahrzeug existiert nicht");
        }
    }
    else
    {
        SendClientMessage(playerid, RED, "SERVER: Du bist nicht als Admin eingeloggt");
    }
    return 1;
}
pawn Код:
CMD:respawn(playerid, params[])
{
    if (IsPlayerAdmin(playerid) || Player[playerid][ALevel] >= 2)
    {
        new command[64];
       
        if (sscanf(params, "s", command))
        {
            SendClientMessage(playerid, RED, "USAGE: /respawn [befehl]");
        }      
        else if (!strcmp(command, "autos", true))
        {
            new pname[256];
            new string[256];
            GetPlayerName(playerid, pname, sizeof(pname));
            format(string, sizeof(string), "*** %s hat die Autos respawnt.", pname);
            SendClientMessageToAll(ORANGE, string);
           
            for (new cars=0; cars<MAX_VEHICLES; cars++)
            {
            SetVehicleToRespawn(cars);
            }
        }
    }
   
    else
    {
        SendClientMessage(playerid, RED, "SERVER: Du bist nicht als Admin eingeloggt oder dein AdminLevel ist zu niedrig");
    }
    return 1;
}
If you need more code just ask for it.
Reply
#2

Код:
[code
for (new cars=0; cars<MAX_VEHICLES; cars++)
{
   SetVehicleToRespawn(cars);
}
The above code will respawn all the vehicles currently in-game.

Try using a array to store the static vehicles you create.

Eg:
Код:
staticcars[]=
{
AddStaticVehicle(................)
//blablabla all your vehicles.
};
Then your respawn commands would be like so:

Код:
for (new cars=0; cars<sizeof(staticcars); cars++)
{
SetVehicleToRespawn(cars);
}
I am not sure, but you can try.
Reply
#3

At first: Thanks,

But how to store the cars?
pawn Код:
new Vehicles[] = {
    {CJ_V1},
    {BALLA_V1},
    {GROVE_V1}
}
thats the way i do
and i get a couple of errors.

Reply
#4

If you use like that, you should put all names in double quotes like:

Код:
new Vehicles[] = 
{
{"CJ_V1"},
{"BALLA_V1"},
{"GROVE_V1"}
}
Reply
#5

Now i get this Error:
Quote:

C:\...\TheKillerzBeta.pwn(80) : error 008: must be a constant expression; assumed zero

my code:
pawn Код:
new StaticVehicles[] =
{
    {"CJ_V1"}, // <-- ERROR
    {"BALLA_V1"},
    {"GROVE_V1"}
}
whats wtong now?
do i have to set the array 2dimensional??
Reply
#6

please ...
Reply
#7

Quote:
Originally Posted by тħeρяш
Now i get this Error:
Quote:

C:\...\TheKillerzBeta.pwn(80) : error 008: must be a constant expression; assumed zero

my code:
pawn Код:
new StaticVehicles[] =
{
    {"CJ_V1"}, // <-- ERROR
    {"BALLA_V1"},
    {"GROVE_V1"}
}
whats wtong now?
do i have to set the array 2dimensional??
pawn Код:
new StaticVehicles[][0] =
{
    {"CJ_V1"},
    {"BALLA_V1"},
    {"GROVE_V1"}
}
try again.
Reply
#8

now that error is fixed, but i get a couple of new ones...
Quote:

C:\...\TheKillerzBeta.pwn(162) : error 046: unknown array size (variable "StaticVehicles")
C:\...\TheKillerzBeta.pwn(163) : error 046: unknown array size (variable "StaticVehicles")
C:\...\TheKillerzBeta.pwn(164) : error 046: unknown array size (variable "StaticVehicles")
C:\...TheKillerzBeta.pwn(1160) : error 033: array must be indexed (variable "StaticVehicles")
C:\...\TheKillerzBeta.pwn(1166) : error 033: array must be indexed (variable "StaticVehicles")
C:\...\TheKillerzBeta.pwn(1172) : error 033: array must be indexed (variable "StaticVehicles")

errors in this lines:
pawn Код:
StaticVehicles[0] = AddStaticVehicleEx(496, 1434.2659912109, -930.6689453125, 36.504253387451, 174.97918701172, 0, 1, 15); // vehicle1 CJ

StaticVehicles[1] = AddStaticVehicleEx(536, 1335.5477294922, -911.88061523438, 35.899898529053, 178.64910888672, 5, 0, 15); // vehicle1 Bala

StaticVehicles[2] = AddStaticVehicleEx(489, 1346.375, -998.220703125, 28.315937042236, 0.000000, -1, -1, 15); // vehicle1 Grove

if (Vehicle == StaticVehicles[0] && gTeam[playerid] != TEAM_CJ)

else if (Vehicle == StaticVehicles[1] && gTeam[playerid] != TEAM_BALLA)

else if (Vehicle == StaticVehicles[2] && gTeam[playerid] != TEAM_GROVE)

Reply
#9

Quote:
Originally Posted by тħeρяш
now that error is fixed, but i get a couple of new ones...
Quote:

C:\...\TheKillerzBeta.pwn(162) : error 046: unknown array size (variable "StaticVehicles")
C:\...\TheKillerzBeta.pwn(163) : error 046: unknown array size (variable "StaticVehicles")
C:\...\TheKillerzBeta.pwn(164) : error 046: unknown array size (variable "StaticVehicles")
C:\...TheKillerzBeta.pwn(1160) : error 033: array must be indexed (variable "StaticVehicles")
C:\...\TheKillerzBeta.pwn(1166) : error 033: array must be indexed (variable "StaticVehicles")
C:\...\TheKillerzBeta.pwn(1172) : error 033: array must be indexed (variable "StaticVehicles")

errors in this lines:
pawn Код:
StaticVehicles[0] = AddStaticVehicleEx(496, 1434.2659912109, -930.6689453125, 36.504253387451, 174.97918701172, 0, 1, 15); // vehicle1 CJ

StaticVehicles[1] = AddStaticVehicleEx(536, 1335.5477294922, -911.88061523438, 35.899898529053, 178.64910888672, 5, 0, 15); // vehicle1 Bala

StaticVehicles[2] = AddStaticVehicleEx(489, 1346.375, -998.220703125, 28.315937042236, 0.000000, -1, -1, 15); // vehicle1 Grove

if (Vehicle == StaticVehicles[0] && gTeam[playerid] != TEAM_CJ)

else if (Vehicle == StaticVehicles[1] && gTeam[playerid] != TEAM_BALLA)

else if (Vehicle == StaticVehicles[2] && gTeam[playerid] != TEAM_GROVE)

forget about the

Quote:
Originally Posted by Pandabeer1337
pawn Код:
new StaticVehicles[][0] =
{
    {"CJ_V1"},
    {"BALLA_V1"},
    {"GROVE_V1"}
}
and just do:

pawn Код:
new StaticVehicles[3];
And increase when you add more vehicles.
Reply
#10

Okay i'll try now and edit the post if it works/doesnt work
Reply
#11

Hm now i dont get errors, but now the cars dont get respawned.

and another question.
i set the respawn_delay to -1 and the vehicles are still autorespawning when they get destroyed.?

EXAMPLE:
pawn Код:
else if (!strcmp(params[0], gObjects[0], true))
{
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
   
    CreateVehicle(522, x-3, y, z+5, a, 0, 0, -1);
}
Reply
#12

okay i now fixed the problem with no respawning. (i had to use <= because i tried it with the last vehicleid)
but there is still the problem, that the cars, i created are autospawning. what did i do wrong?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)