nrg/inf command destroy -
MonSterLikeHD - 27.03.2016
Hi, one of my friend give me this script for a nrg/inf car spawner, this is the script:
{
new Float:Pos[4],inf;
new Float:Pose[4],nrg;
if(!strcmp(cmdtext,"/inf",true))
{
GetPlayerPos(playerid,Pos[1],Pos[2],Pos[3]);
inf=CreateVehicle(411,Pos[1],Pos[2],Pos[3],0,-1,-1,10);
PutPlayerInVehicle(playerid,inf, 0);
SendClientMessage(playerid,0xFF641AFF,"SERVER: You have Spawned An Infernus.");
return 1;
}
if(!strcmp(cmdtext,"/nrg",true))
{
GetPlayerPos(playerid,Pose[1],Pose[2],Pose[3]);
nrg=CreateVehicle(522,Pose[1],Pose[2],Pose[3],0,-1,-1,10);
PutPlayerInVehicle(playerid,nrg, 0);
SendClientMessage(playerid,0xFF641AFF,"SERVER: You have Spawned An NRG-500.");
return 1;
}
return 0;
}
But my problem is, when i use de command, when i am in the vehicle and i type the command again, the previosly car dosen't destroy, and if i spawn de car, and i go outside the car and i type the command agaain the previos car dosen't destroy... pls help i give rep
Re: nrg/inf command destroy -
Abagail - 27.03.2016
I'd advise using ZCMD to process commands rather than the old strcmp method.
pawn Код:
new LastVehicle[MAX_PLAYERS] = INVALID_VEHICLE_ID;
CMD:inf(playerid, params[]) {
if(GetVehicleModel(LastVehicle[playerid]) == 411) DestroyVehicle(LastVehicle[playerid]);
new Float: x, Float: y, Float: z;
GetPlayerPos(playerid, x, y, z);
LastVehicle[playerid] = CreateVehicle(411, x, y, z, GetPlayerFacingAngle(playerid), -1, -1, 10);
if(!GetVehicleModel(LastVehicle[playerid])) return SendClientMessage(playerid, -1, "Unable to spawn the infernus.");
PutPlayerInVehicle(playerid, LastVehicle[playerid], 0);
SendClientMessage(playerid, 0xFF641AFF, "SERVER: You have spawned an infernus.");
return 1;
}
CMD:inf(playerid, params[]) {
if(GetVehicleModel(LastVehicle[playerid]) == 522) DestroyVehicle(LastVehicle[playerid]);
new Float: x, Float: y, Float: z;
GetPlayerPos(playerid, x, y, z);
LastVehicle[playerid] = CreateVehicle(522, x, y, z, GetPlayerFacingAngle(playerid), -1, -1, 10);
if(!GetVehicleModel(LastVehicle[playerid])) return SendClientMessage(playerid, -1, "Unable to spawn the NRG.");
PutPlayerInVehicle(playerid, LastVehicle[playerid], 0);
SendClientMessage(playerid, 0xFF641AFF, "SERVER: You have spawned an NRG.");
return 1;
}
Re: nrg/inf command destroy -
MonSterLikeHD - 27.03.2016
But where is the command ? or i need to put what you give me in there with my command ?
Re: nrg/inf command destroy -
Crystallize - 27.03.2016
Just download zcmd include
on top of your script after a_samp add
#include <zcmd>
and somewhere in your script paste those Abagail posted , don't paste them Onplayercommandtext or it won't work.
Re: nrg/inf command destroy -
MonSterLikeHD - 28.03.2016
so dosen't matter where i put these right ?
Re: nrg/inf command destroy -
introzen - 28.03.2016
You will need this, (if you haven't already):
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(vehicleid == nrj || vehicleid == inf)
{
DestroyVehicle(vehicleid);
}
return 1;
}
Also check if player is in vehicle on the command text. If player is in vehicle, check wether it's nrj or inf, then destroy.