SA-MP Forums Archive
disable auto repair/fix of veh if player is in DM - 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: disable auto repair/fix of veh if player is in DM (/showthread.php?tid=468970)



disable auto repair/fix of veh if player is in DM - gotwarzone - 11.10.2013

Hi I have a auto/repair fix in my server. And I made a /cs - deathmatch where there are vehicle tanks and other dm vehicles. But everytime I hit them with rockets machineguns it autofix/repair. So whats the use of deathmatch then right? Can you please help me how to disable it? Thanks


Re: disable auto repair/fix of veh if player is in DM - mahdi499 - 11.10.2013

I would help you if you show me some code.....

Probably add a variable that's true outside dm arena and false inside it.


Re: disable auto repair/fix of veh if player is in DM - gotwarzone - 11.10.2013

Quote:
Originally Posted by mahdi499
Посмотреть сообщение
I would help you if you show me some code.....

Probably add a variable that's true outside dm arena and false inside it.
Oops I forgot to show the codes here it is...

Under onplayerconnect
Код:
SetTimerEx("VRepair",500,true,"i",playerid);
Код:
forward VRepair(playerid);
public VRepair(playerid)
{
    if(IsPlayerInAnyVehicle(playerid)) RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
Deathmatch area
Код:
new str[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(str, sizeof(str), "{09F7DF}(/cs) {ffd700}%s {09F7DF}has Teleported to Counter-Strike Deathmatch",pName);
GameTextForPlayer(playerid,"~y~Welcome to ~n~~b~Counter-Strike",2000,3);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SetPlayerVirtualWorld(playerid, 11);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
SaveWeapons(playerid);
ResetPlayerWeapons(playerid); //must be added before this
GivePlayerWeapon(playerid, 41, 100000);
GivePlayerWeapon(playerid, 24, 100000);
GivePlayerWeapon(playerid, 26, 100000);
GivePlayerWeapon(playerid, 28, 100000);
GivePlayerWeapon(playerid, 30, 100000);
GivePlayerWeapon(playerid, 33, 100000);
DestroyVehicle(GetPlayerVehicleID(playerid));
SendClientMessageToAll(0xFFFFFFFF, str);
new Random = random(sizeof(RandomSpawnCsDM));
SetPlayerPos(playerid, RandomSpawnCsDM[Random][0], RandomSpawnCsDM[Random][1], RandomSpawnCsDM[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnCsDM[Random][3]);
return 1;
}



Re: disable auto repair/fix of veh if player is in DM - xVIP3Rx - 11.10.2013

Add an Id to the timer and kill it when the player is inside the area then start it again,
pawn Код:
new TimerId[MAX_PLAYERS];
TimerId[playerid] = SetTimerEx("VRepair",500,true,"i",playerid);
pawn Код:
new str[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(str, sizeof(str), "{09F7DF}(/cs) {ffd700}%s {09F7DF}has Teleported to Counter-Strike Deathmatch",pName);
GameTextForPlayer(playerid,"~y~Welcome to ~n~~b~Counter-Strike",2000,3);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SetPlayerVirtualWorld(playerid, 11);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
SaveWeapons(playerid);
ResetPlayerWeapons(playerid); //must be added before this
GivePlayerWeapon(playerid, 41, 100000);
GivePlayerWeapon(playerid, 24, 100000);
GivePlayerWeapon(playerid, 26, 100000);
GivePlayerWeapon(playerid, 28, 100000);
GivePlayerWeapon(playerid, 30, 100000);
GivePlayerWeapon(playerid, 33, 100000);
DestroyVehicle(GetPlayerVehicleID(playerid));
SendClientMessageToAll(0xFFFFFFFF, str);
new Random = random(sizeof(RandomSpawnCsDM));
SetPlayerPos(playerid, RandomSpawnCsDM[Random][0], RandomSpawnCsDM[Random][1], RandomSpawnCsDM[Random][2]);
SetPlayerFacingAngle(playerid, RandomSpawnCsDM[Random][3]);
KillTimer(TimerId[playerid]); // Here to stop repairing the car, You have to set the timer again when player leave the area
return 1;
}



Re: disable auto repair/fix of veh if player is in DM - mahdi499 - 11.10.2013

What i can suggest is

pawn Код:
new Allowed[MAX_PLAYERS];
public VRepair(playerid)
{
    if(IsPlayerInAnyVehicle(playerid) && Allowed == 1) RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
and make it when player enters DM arena Allowed = 0 and when he Exits Allowed = 1


Re: disable auto repair/fix of veh if player is in DM - kbalor - 11.10.2013

EDIT:


Re: disable auto repair/fix of veh if player is in DM - gotwarzone - 11.10.2013

Quote:
Originally Posted by mahdi499
Посмотреть сообщение
What i can suggest is

pawn Код:
new Allowed[MAX_PLAYERS];
public VRepair(playerid)
{
    if(IsPlayerInAnyVehicle(playerid) && Allowed == 1) RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
and make it when player enters DM arena Allowed = 0 and when he Exits Allowed = 1
Good Idea. But why this warning shows up?

Код:
error 033: array must be indexed (variable "Allowed")
also if its okay to you if you can show to whole script for this?

this what you wrote "and make it when player enters DM arena Allowed = 0 and when he Exits Allowed = 1"

To xVIP3Rx : i will try youyrs

EDIT: viper it still repairs.


Re: disable auto repair/fix of veh if player is in DM - xVIP3Rx - 11.10.2013

Quote:
Originally Posted by gotwarzone
Посмотреть сообщение
Good Idea. But why this warning shows up?

Код:
error 033: array must be indexed (variable "Allowed")
also if its okay to you if you can show to whole script for this?

this what you wrote "and make it when player enters DM arena Allowed = 0 and when he Exits Allowed = 1"

To xVIP3Rx : i will try youyrs

EDIT: viper it still repairs.
The fix for the first one is. You shuold add [playerid]
Here..
pawn Код:
new Allowed[MAX_PLAYERS];
public VRepair(playerid)
{
    if(IsPlayerInAnyVehicle(playerid) && Allowed[playerid] == 1) RepairVehicle(GetPlayerVehicleID(playerid));
    return 1;
}
And if you wanna use mine, You should make the timer id a global not local.. If you didn't do that already


Re: disable auto repair/fix of veh if player is in DM - gotwarzone - 11.10.2013

thanks works like a charm! +rep both


Re: disable auto repair/fix of veh if player is in DM - mahdi499 - 11.10.2013

Yeah sorry,haven't touch pawno for a long time,so i didn't remember to add [playerid]