PDA

View Full Version : Reps , Help , Fast please:S


MahdiGames
28/01/2014, 05:15 PM
I need a function that destroy vehicle like "DestroyVehicle(playerid);", I'v tried some functions like:"

for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInVehicle(i, vehid)) return 1;
}
}

But its destroy vehicles which are not occupation , please help i want code thats when player death destroy his car, and when exit from server and when exit from vehicle thanks !

public OnPlayerDisconnect(playerid, reason)
{
//AnyFunction Destroy the playerid vehicle when he leave if he was on vehicle.
return 1;
}
OnPlayerExitVehicle(p...)
{
//Send timer to destroy his vehicle if he not back with 1 min
return 1;
}
OnPlayerDeath
{
//Destroy playerid vehicle
}

Abagail
28/01/2014, 05:18 PM
Can you show a litte more code? We have no idea what this even goes along with...

Smileys
28/01/2014, 05:28 PM
if( IsPlayerInVehicle( playerid, playercar ) );

DestroyVehicle( playercar );

MahdiGames
28/01/2014, 05:33 PM
if( IsPlayerInVehicle( playerid, playercar ) );

DestroyVehicle( playercar );

Thanks for trying to help is there are better function

[WSF]ThA_Devil
28/01/2014, 05:37 PM
Thanks for trying to help is there are better function

You have to work with functions that you're given....

try:
if(IsPlayerInAnyVehicle(playerid){
DestroyVehicle(GetPlayerVehicleID(playerid));
}

MahdiGames
28/01/2014, 05:52 PM
ThA_Devil;2888324']You have to work with functions that you're given....

try:
if(IsPlayerInAnyVehicle(playerid){
DestroyVehicle(GetPlayerVehicleID(playerid));
}

Not worked :S

[WSF]ThA_Devil
28/01/2014, 05:55 PM
Not worked :S

Did it compile without errors? Since I typed it from my head....

MahdiGames
28/01/2014, 05:57 PM
ThA_Devil;2888347']Did it compile without errors? Since I typed it from my head....

Yes, in the fact i fixed onplayerdeath on player disconnect i need one for onplayerexit vehicle

Abagail
28/01/2014, 05:59 PM
public OnPlayerDisconnect(playerid, reason)
{
if(!IsPlayerInAnyVehicle) return 0;
DestroyVehicle(GetPlayerVehicleID(playerid));
return 1;
}
OnPlayerExitVehicle(p...)
{
SetTimerEx("DestroyVehicle", 10000, false, "i", playerid);
SetPVarInt(playerid, "DestroyVehicle", vehicleid)
}
return 1;
}
OnPlayerDeath
{
if(!IsPlayerInAnyVehicle) return 0;
DestroyVehicle(GetPlayerVehicleID(playerid));
}

public DestroyVehicle(playerid)
{
new vehicleid == GetPVarInt(playerid, "DestroyVehicle");
DestroyVehicle(vehicleid);
}

Untested.

MahdiGames
28/01/2014, 06:04 PM
public OnPlayerDisconnect(playerid, reason)
{
if(!IsPlayerInAnyVehicle) return 0;
DestroyVehicle(GetPlayerVehicleID(playerid));
return 1;
}
OnPlayerExitVehicle(p...)
{
SetTimerEx("DestroyVehicle", 10000, false, "i", playerid);
SetPVarInt(playerid, "DestroyVehicle", vehicleid)
}
return 1;
}
OnPlayerDeath
{
if(!IsPlayerInAnyVehicle) return 0;
DestroyVehicle(GetPlayerVehicleID(playerid));
}

public DestroyVehicle(playerid)
{
new vehicleid == GetPVarInt(playerid, "DestroyVehicle");
DestroyVehicle(vehicleid);
}

Untested.

C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(150) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(167) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(183) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(213) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(260) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(6709) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(9456) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(9470) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(9485) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(9499) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(9746) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(9947) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(9954) : error 021: symbol already defined: "DestroyVehicle"
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(9956) : error 001: expected token: ";", but found "=="
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(9961) : warning 219: local variable "vehicleid" shadows a variable at a preceding level
C:\Users\MaHdy\Desktop\SPA Server original\gamemodes\SPA.pwn(10279) : warning 203: symbol is never used: "vehicleid"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

Abagail
28/01/2014, 06:10 PM
Change it to:
OnPlayerExitVehicle(p...)
{
SetTimerEx("DestroyVehicleTimed", 10000, false, "i", playerid);
SetPVarInt(playerid, "DestroyVehicle", vehicleid)
}
return 1;
}
public DestroyVehicleTimed(playerid)
{
new vehicleid = GetPVarInt(playerid, "DestroyVehicle");
DestroyVehicle(vehicleid);
}

EDIT: My bad... I should've tested it... But anyways, this should work.

MahdiGames
28/01/2014, 06:22 PM
Change it to:
OnPlayerExitVehicle(p...)
{
SetTimerEx("DestroyVehicleTimed", 10000, false, "i", playerid);
SetPVarInt(playerid, "DestroyVehicle", vehicleid)
}
return 1;
}
public DestroyVehicleTimed(playerid)
{
new vehicleid = GetPVarInt(playerid, "DestroyVehicle");
DestroyVehicle(vehicleid);
}

EDIT: My bad... I should've tested it... But anyways, this should work.

Mmmmmmmmmmmmm :P

C:\Users\MaHdy\Desktop\SPA.pwn(9951) : error 001: expected token: ";", but found "}"
C:\Users\MaHdy\Desktop\SPA.pwn(9952) : error 010: invalid function or declaration
C:\Users\MaHdy\Desktop\SPA.pwn(9954) : warning 235: public function lacks forward declaration (symbol "DestroyVehicleTimed")
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

Abagail
28/01/2014, 06:28 PM
What's line 9951 and 9952?

Abagail
28/01/2014, 06:32 PM
EDIT:
Okay, I'll test it this time...

OnPlayerExitVehicle(p...)
{
SetTimerEx("DestroyVehicleTimed", 10000, false, "i", playerid);
SetPVarInt(playerid, "DestroyVehicle", vehicleid);
}
return 1;
}
public DestroyVehicleTimed(playerid)
{
new vehicleid = GetPVarInt(playerid, "DestroyVehicle");
DestroyVehicle(vehicleid);
}

Tested. Works.

"This forum requires that you wait 240 seconds between posts. Please try again in 49 seconds."

MahdiGames
28/01/2014, 06:42 PM
EDIT:
Okay, I'll test it this time...

OnPlayerExitVehicle(p...)
{
SetTimerEx("DestroyVehicleTimed", 10000, false, "i", playerid);
SetPVarInt(playerid, "DestroyVehicle", vehicleid);
}
return 1;
}
public DestroyVehicleTimed(playerid)
{
new vehicleid = GetPVarInt(playerid, "DestroyVehicle");
DestroyVehicle(vehicleid);
}

Tested. Works.

"This forum requires that you wait 240 seconds between posts. Please try again in 49 seconds."
Sorry same errors
C:\Users\MaHdy\Desktop\SPA.pwn(9952) : error 010: invalid function or declaration
C:\Users\MaHdy\Desktop\SPA.pwn(9954) : warning 235: public function lacks forward declaration (symbol "DestroyVehicleTimed")
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

EDIT:

isnt this code better

public OnPlayerExitVehicle(playerid, vehicleid)
{
SetTimerEx("DesVeh", 60000, 0, "i", vehicleid);
SetPVarInt(playerid, "DestroyVehicle", vehicleid);
return 1;
}


forward DesVeh(vehid);
public DesVeh(vehid)
{
GetPVarInt(vehid, "DestroyVehicle");
DestroyVehicle(vehid);
return 1;
}

Abagail
28/01/2014, 07:01 PM
I didn't get the error you did... But if that code works use it.