shorter code, help. - 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: shorter code, help. (
/showthread.php?tid=310981)
shorter code, help. -
Buwla - 14.01.2012
Hello, I have 4 vehicle slots, and I want this command to choose from 1-4 depending on if the vehicle slot is empty or not. In other words, I want it to pick the first vehicle slot thats not empty, and I want it to be as short as possible.
This is my command, for now it only picks the vehicle from slot one.
pawn Код:
YCMD:car(playerid, params[],help)
{
if(help)
{
SendClientMessage(playerid, 0xFF0000AA, "nope");
}
else
{
#pragma unused params
if(SpawnedVehicles[playerid] != 0) DestroyVehicle(SpawnedVehicles[playerid]);
new
Float:X, Float:Y, Float:Z,
Float:Angle,int1,
vehicle = PlayerInfo[playerid][pVehicle1];
GetPlayerFacingAngle(playerid,Angle);
GetPlayerPos(playerid, X,Y,Z);
int1 = GetPlayerInterior(playerid);
SpawnedVehicles[playerid] = CreateVehicle(vehicle, X,Y,Z, Angle, -1, -1, -1);
LinkVehicleToInterior(vehicle,int1);
PutPlayerInVehicle(playerid,SpawnedVehicles[playerid],0);
}
return 1;
}
I've been away from this for a long time, and I just started using YCMD, so if theres any major errors, let me know.