SA-MP Forums Archive
Problems with /v command - 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: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problems with /v command (/showthread.php?tid=123809)



Problems with /v command - biltong - 27.01.2010

I've just swapped over to zcmd, and all my other commands work, but this one doesn't:

pawn Код:
zcmd(v, playerid, params[])
{
    new vehicle, string[128];
    if (!sscanf(params, "i", vehicle))
    {
      new Float:x,Float:y, Float:z, Float:angle;
      GetPlayerPos(playerid,x,y,z);
      GetPlayerFacingAngle(playerid,angle);
      CreateVehicle(vehicle, x, y, z, angle, 0, 0, 9999999999);
        format(string,sizeof(string),"You have spawned VID %d at your location.",vehicle);
      SendClientMessage(playerid, COLOR_GREEN, string);
    }
    else return SendClientMessage(playerid,COLOR_RED,"USAGE: /v [vehicleid]");
    return 1;
}
It tells me I've spawned for instance VID 520(a hydra) but it doesn't actually spawn anything. I've tried different respawn times but that doesn't seem to work. Is there a max or min?


Re: Problems with /v command - DeathOnaStick - 27.01.2010

You use sscanf wrong.

pawn Код:
zcmd(v, playerid, params[])
{
     new vehicle, string[128];
     if (!sscanf(params, "i", vehicle)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /v [vehicleid]");
     new Float:x,Float:y, Float:z, Float:angle;
     GetPlayerPos(playerid,x,y,z);
     GetPlayerFacingAngle(playerid,angle);
     CreateVehicle(vehicle, x, y, z, angle, 0, 0, 9999999999);
     format(string,sizeof(string),"You have spawned VID %d at your location.",vehicle);
     SendClientMessage(playerid, COLOR_GREEN, string);
     return 1;
}
Didn't you read the Tutorial on the wiki?!

#Added#: I just noticed: If you want the car not to respawn try this:
pawn Код:
CreateVehicle(vehicle, x, y, z, angle, 0, 0, -1);



Re: Problems with /v command - Niixie - 27.01.2010

[/pawn]zcmd(v, playerid, params[])
{
new vehicle, string[128];
if (!sscanf(params, "i", vehicle)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /v [vehicleid]");
else
new Float,Float:y, Float:z, Float:angle;
GetPlayerPos(playerid,x,y,z);
GetPlayerFacingAngle(playerid,angle);
CreateVehicle(vehicle, x, y, z, angle, 0, 0, 9999999999);
format(string,sizeof(string),"You have spawned VID %d at your location.",vehicle);
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}[/pawn]


Re: Problems with /v command - biltong - 27.01.2010

Neither of those work. Both of them give me the USAGE message. It's doing that because the parameters for sscanf are met, it checked for an integer and it got one, so it returned USAGE: /v [vehicleid].

I'm starting to think I hit the vehicle limit. I have tons of em

I did read the wiki BTW

EDIT: I commented most of the vehicles in my server and now my original /v command works, albeit not how I hoped. You have to run away before the vehicle will spawn. Any way to fix that? Also, how would I put the player in the vehicle they just spawned?


Re: Problems with /v command - biltong - 12.02.2010

BUMP

Ok so now I found out I was already at the vehicle limit, so I removed about 300 vehicles and since then the command has worked. Only problem is that the vehicles respawn. I only want my static vehicles to respawn, not the command ones. Here's my code:
pawn Код:
zcmd(v, playerid, params[]) //disabled because these vehicles respawn, they shouldn't :/
{
    new vehicle, string[46];
    if (!sscanf(params, "i", vehicle))
    {
        new Float:x,Float:y, Float:z, Float:angle;
    GetPlayerPos(playerid,x,y,z);
    GetPlayerFacingAngle(playerid,angle);
    format(string,sizeof(string),"You have spawned VID %d at your location.",vehicle);
    SendClientMessage(playerid, COLOR_GREEN, string);
    new vehicleid = CreateVehicle(vehicle, x, y, z, angle, -1, -1, -1);
        ShouldntVehicleRespawn[vehicleid] += 1;
        PutPlayerInVehicle(playerid,vehicleid,0);
        SetVehicleVirtualWorld(vehicleid,GetPlayerVirtualWorld(playerid));
        LinkVehicleToInterior(vehicleid,GetPlayerInterior(playerid));
    }
    else return SendClientMessage(playerid,COLOR_RED,"USAGE: /v [vehicleid]");
    return 1;
}
Solution?


Re: Problems with /v command - MadeMan - 12.02.2010

How do you use this?

pawn Код:
ShouldntVehicleRespawn[vehicleid]
By not respawn you mean that vehicle will be deleted after spawning?

Then use OnVehicleSpawn and that variable.


Re: Problems with /v command - biltong - 12.02.2010

What? No idea what you just said

EDIT: Oic. ShouldntVehicleRespawn is a variable that was defined as ShouldntVehicleRespawn[MAX_VEHICLES] and I have a function that checks if a vehicle id has that variable associated with it, and sets all other vehicles except that vehicle to respawn.


Re: Problems with /v command - MadeMan - 12.02.2010

What do you mean you don't want them to respawn? What happens if they are destroyed?


Re: Problems with /v command - biltong - 13.02.2010

When they get destroyed, they respawn at the place the player spawned them at. even setting respawn time to -1 or infinity didnt work, and there's nothing else in my script telling vehicles to respawn.


Re: Problems with /v command - mansonh - 13.02.2010

If you want vehicles that are destroyed to not respawn use
Код:
public OnVehicleDeath(vehicleid, killerid)
{
  DestroyVehicle(vehicleid);
}