SA-MP Forums Archive
vehicle spawner - 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: vehicle spawner (/showthread.php?tid=320322)



vehicle spawner - Fires - 22.02.2012

I don't understand why my vehicle spawner don't work..
this is an example

pawn Код:
if (!strcmp("/PoliceLS", cmdtext, true))
    {
        if(SpawnedVehicles[playerid] != 0) DestroyVehicle(SpawnedVehicles[playerid]);
        new Float:X,Float:Y,Float:Z,Float:ROT;
        GetPlayerPos(playerid,X,Y,Z);
        GetPlayerFacingAngle (playerid,ROT);
        SpawnedVehicles[playerid] = CreateVehicle(596,X,Y,Z,ROT,-1,-1,60);
        PutPlayerInVehicle(playerid,SpawnedVehicles[playerid],0);
        GameTextForPlayer(playerid,"~h~~w~Police LS~n~~h~~w~ID:~h~~r~596",2500,1);
        return 1;
}
i hanven't any error or warning.. but vehicle doesn't spawn when i type the cmd
Please help me..


Re: hel vehicle spawner - Opah - 24.06.2012

try this but i dont understand the SpawnedVehicles[playerid]
Код:
if (!strcmp("/PoliceLS", cmdtext, true))
{
    if(IsPlayerInAnyVehicle(playerid)) { DestroyVehicle(GetPlayerVehicleID(playerid)); }
    new Float:X,Float:Y,Float:Z,Float:ROT;
    new PoliceLSv;
    GetPlayerPos(playerid,X,Y,Z);
    GetPlayerFacingAngle (playerid,ROT);
    PoliceLSv = CreateVehicle(596,X,Y,Z,ROT,-1,-1,60);
    PutPlayerInVehicle(playerid,PoliceLSv,0);
    GameTextForPlayer(playerid,"~h~~w~Police LS~n~~h~~w~ID:~h~~r~596",2500,1);
    return 1;
}



Re: hel vehicle spawner - Opah - 29.06.2012

Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 100 //change this to ur maximum players slots
new SpawnedVehicles[MAX_PLAYERS];
Код:
if (!strcmp("/PoliceLS", cmdtext, true))
{
    if(SpawnedVehicles[playerid] != 0) {DestroyVehicle(SpawnedVehicles[playerid]);}
    if(IsPlayerInAnyVehicle(playerid)) { DestroyVehicle(GetPlayerVehicleID(playerid)); }
    new Float:X,Float:Y,Float:Z,Float:ROT;
    new PoliceLSv;
    GetPlayerPos(playerid,X,Y,Z);
    GetPlayerFacingAngle (playerid,ROT);
    PoliceLSv = CreateVehicle(596,X,Y,Z,ROT,-1,-1,60);
    PutPlayerInVehicle(playerid,PoliceLSv,0);
    GameTextForPlayer(playerid,"~h~~w~Police LS~n~~h~~w~ID:~h~~r~596",2500,1);
    SpawnedVehicles[playerid] = CreateVehicle(596,X,Y,Z,ROT,-1,-1,60);
    return 1;
}



Re: vehicle spawner - [A]ndrei - 29.06.2012

put these on top
Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 100 //change this to ur maximum players slots
new SpawnedVehicles[MAX_PLAYERS];
and this for the command
Код:
if (!strcmp("/PoliceLS", cmdtext, true))
{
    if(IsPlayerInAnyVehicle(playerid)) { DestroyVehicle(GetPlayerVehicleID(playerid)); }
    new Float:X,Float:Y,Float:Z,Float:ROT;
    new PoliceLSv;
    GetPlayerPos(playerid,X,Y,Z);
    GetPlayerFacingAngle (playerid,ROT);
    PoliceLSv = CreateVehicle(596,X,Y,Z,ROT,-1,-1,60);
    PutPlayerInVehicle(playerid,PoliceLSv,0);
    GameTextForPlayer(playerid,"~h~~w~Police LS~n~~h~~w~ID:~h~~r~596",2500,1);
    return 1;
}



Re: vehicle spawner - Gangster-rocks - 29.06.2012

pawn Код:
if (!strcmp("/PoliceLS", cmdtext, true))
    {
        if(SpawnedVehicles[playerid] != 0) DestroyVehicle(SpawnedVehicles[playerid]);
        new Float[4]
        GetPlayerPos(playerid,Float[0],Float[1],Float[2]);
        GetPlayerFacingAngle (playerid,Float[3]);
        SpawnedVehicles[playerid] = CreateVehicle(596,Float[0],Float[1],Float[2],Float[3],-1,-1,60);
        PutPlayerInVehicle(playerid,SpawnedVehicles[playerid],0);
        GameTextForPlayer(playerid,"~h~~w~Police LS~n~~h~~w~ID:~h~~r~596",2500,1);
        return 1;
}
Complied and tested.


Re: vehicle spawner - AndreT - 29.06.2012

Quote:
Originally Posted by Gangster-rocks
Посмотреть сообщение
pawn Код:
if (!strcmp("/PoliceLS", cmdtext, true))
    {
        if(SpawnedVehicles[playerid] != 0) DestroyVehicle(SpawnedVehicles[playerid]);
        new Float[4]
        GetPlayerPos(playerid,Float[0],Float[1],Float[2]);
        GetPlayerFacingAngle (playerid,Float[3]);
        SpawnedVehicles[playerid] = CreateVehicle(596,Float[0],Float[1],Float[2],Float[3],-1,-1,60);
        PutPlayerInVehicle(playerid,SpawnedVehicles[playerid],0);
        GameTextForPlayer(playerid,"~h~~w~Police LS~n~~h~~w~ID:~h~~r~596",2500,1);
        return 1;
}
Complied and tested.
COMPLIED? Maybe, but probably not compiled.

pawn Код:
new Float[4]
GetPlayerPos(playerid,Float[0],Float[1],Float[2]);
GetPlayerFacingAngle (playerid,Float[3]);
My logic does not catch it - how can code like this work? There's even no line ending on line #1 there. Also I assume the variable will need a name, a simple Float won't do as that's a tag (Float.