Personal Vehicle Help! -
necrobg3 - 16.08.2012
Hello forum samp.
Im trying to make a personal veh command.
When i type /elegy - to spawn an elegy , when i type /elegy second time the first car get destroyed not with DestroyVehicle but with the command. I mean if i exit the car let the first car get destroyed automaticly by the command.
I tried to make it many times in much diferrent ways ,but nothing happened.
So i am stuck here.
Код:
if (strcmp("/elegy", cmdtext, true, 10) == 0)
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You already have a car.");
new Float:X, Float:Y, Float:Z, elegy;
GetPlayerPos(playerid, X, Y, Z);
elegy = CreateVehicle(562, X, Y, Z, 0.0, 0, 0, 0);
PutPlayerInVehicle(playerid, elegy, 0);
return 1;
}
Any ideas? +Rep for the dude who will help me.
Re: Personal Vehicle Help! -
necrobg3 - 17.08.2012
Please guys i really need that command.
Re: Personal Vehicle Help! -
FalconX - 17.08.2012
Quote:
Originally Posted by necrobg3
Please guys i really need that command.
|
There is not really need of szSavePlayerVeh variable but I just made it to make you understand. We can also do this
pawn Код:
DestroyVehicle( GetPlayerVehicleID( playerid ) );
anyway, full code:
pawn Код:
new szSavePlayerVeh[ MAX_PLAYERS ],
bool:n_biIsPlayerInCar[ MAX_PLAYERS ]; // at top
n_biIsPlayerInCar[ playerid ] = false; //in nPlayerConnect and OnPlayerDIsconnect
if (strcmp("/elegy", cmdtext, true, 10) == 0)
{
if( IsPlayerInAnyVehicle( playerid ) ) return SendClientMessage(playerid, COLOR_RED, "ERROR: You already have a car.");
if( !n_biIsPlayerInCar[ playerid ] )
{
new Float:X, Float:Y, Float:Z, elegy;
GetPlayerPos(playerid, X, Y, Z);
elegy = CreateVehicle(562, X, Y, Z, 0.0, 0, 0, 0);
PutPlayerInVehicle(playerid, elegy, 0);
n_biIsPlayerInCar[ playerid ] = true;
szSavePlayerVeh[ playerid ] = GetPlayerVehicleID( playerid );
}
else
{
n_biIsPlayerInCar[ playerid ] = false;
DestroyVehicle( szSavePlayerVeh[ playerid ] );
}
return 1;
}
Did you mean this?
Re: Personal Vehicle Help! -
necrobg3 - 17.08.2012
Quote:
Originally Posted by FalconX
There is not really need of szSavePlayerVeh variable but I just made it to make you understand. We can also do this
pawn Код:
DestroyVehicle( GetPlayerVehicleID( playerid ) );
anyway, full code:
pawn Код:
new szSavePlayerVeh[ MAX_PLAYERS ], bool:n_biIsPlayerInCar[ MAX_PLAYERS ]; // at top n_biIsPlayerInCar[ playerid ] = false; //in nPlayerConnect and OnPlayerDIsconnect
if (strcmp("/elegy", cmdtext, true, 10) == 0) { if( IsPlayerInAnyVehicle( playerid ) ) return SendClientMessage(playerid, COLOR_RED, "ERROR: You already have a car.");
if( !n_biIsPlayerInCar[ playerid ] ) {
new Float:X, Float:Y, Float:Z, elegy; GetPlayerPos(playerid, X, Y, Z); elegy = CreateVehicle(562, X, Y, Z, 0.0, 0, 0, 0); PutPlayerInVehicle(playerid, elegy, 0); n_biIsPlayerInCar[ playerid ] = true; szSavePlayerVeh[ playerid ] = GetPlayerVehicleID( playerid ); } else { n_biIsPlayerInCar[ playerid ] = false; DestroyVehicle( szSavePlayerVeh[ playerid ] ); } return 1; }
Did you mean this?
|
Not really, i mean when i type /elegy to destroy the vehicle and thats happen , but now when i type it it only destroys not spawn so i need when i type /elegy second time the elegy get destroyed and spawned in one way.
Re: Personal Vehicle Help! -
necrobg3 - 17.08.2012
Any help please?
AW: Personal Vehicle Help! -
Nero_3D - 17.08.2012
pawn Код:
// OnPlayerCommandText
if(strcmp("/elegy", cmdtext, true) == 0) {
if(IsPlayerInAnyVehicle(playerid)) {
return SendClientMessage(playerid, COLOR_RED, "ERROR: You already have a car.");
}
static
vehicleid
;
if(vehicleid) {
DestroyVehicle(vehicleid);
}
new
Float: X,
Float: Y,
Float: Z
;
GetPlayerPos(playerid, X, Y, Z);
PutPlayerInVehicle(playerid, (vehicleid = CreateVehicle(562, X, Y, Z, 0.0, -1, -1, -1)), 0);
return true;
}
Re: Personal Vehicle Help! -
necrobg3 - 17.08.2012
Thanks, just one more thing. When i type /elegy the car get spawned but not on my current facing angle. Can this be fixed?
AW: Re: Personal Vehicle Help! -
Nero_3D - 17.08.2012
Quote:
Originally Posted by necrobg3
Thanks, just one more thing. When i type /elegy the car get spawned but not on my current facing angle. Can this be fixed?
|
pawn Код:
// OnPlayerCommandText
if(strcmp("/elegy", cmdtext, true) == 0) {
if(IsPlayerInAnyVehicle(playerid)) {
return SendClientMessage(playerid, COLOR_RED, "ERROR: You already have a car.");
}
static
vehicleid
;
if(vehicleid) {
DestroyVehicle(vehicleid);
}
new
Float: X,
Float: Y,
Float: Z,
Float: A
;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
PutPlayerInVehicle(playerid, (vehicleid = CreateVehicle(562, X, Y, Z, A, -1, -1, -1)), 0);
return true;
}
Re: Personal Vehicle Help! -
necrobg3 - 17.08.2012
Thanks dude, +rep for you.