disable auto repair/fix of veh if player is in DM
#1

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
Reply
#2

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

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

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;
}
Reply
#4

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;
}
Reply
#5

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
Reply
#6

EDIT:
Reply
#7

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.
Reply
#8

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
Reply
#9

thanks works like a charm! +rep both
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)