PDA

View Full Version : Anti Team Jack


Sting.
26/07/2017, 10:33 AM
Well guys, I need your help on Anti Team jack. Can someone provide me the code to do so? I have set the teams with SetPlayerTeam(playerid, IDs). I just need help now, on making it Anti-Team jack. +REP for those who help with this. My hands are just tied with other things. Thanks in advance.

xMoBi
26/07/2017, 10:35 AM
The code will go under OnPlayerEnterVehicle, loop the players, if the team mate in the vehicle is a driver, break the loop and stop him.

Sting.
26/07/2017, 10:36 AM
But could you provide the code, that would be big help. Thanks.

StrikerZ
26/07/2017, 10:39 AM
stock GetDriverID(vehicleid)
{
for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) //Loops through all players
{
if(GetPlayerVehicleID(i) == vehicleid && GetPlayerState(i) == PLAYER_STATE_DRIVER) return i;
}
return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new id = GetDriverID(vehicleid);
if(IsPlayerInAnyVehicle(id) && !ispassenger && GetPlayerTeam(playerid) == GetPlayerTeam(id))
{
// your code to kick him out
}
return 1;
}

Sting.
26/07/2017, 10:51 AM
My code to kick him out, was just ClearAnimations(playerid); so that the animation will stop. I placed the stock below my script, compiled it and found no errors. Problem is can't test, how it works fine.

StrikerZ
26/07/2017, 10:54 AM
It'll work.

Sting.
26/07/2017, 10:58 AM
Alright, +REP to you guys. I will be able to try this weekend, if I find errors, I'll repost here. Thanks to both of ya'll.

R4nd4ll
26/07/2017, 11:18 AM
Alright, +REP to you guys. I will be able to try this weekend, if I find errors, I'll repost here. Thanks to both of ya'll.

I know its a dumb suggestion, But it can add a cool feature to your script.

Add SendClienMessage to it

So it will be :
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new id = GetDriverID(vehicleid);
if(IsPlayerInAnyVehicle(id) && !ispassenger && GetPlayerTeam(playerid) == GetPlayerTeam(id))
{
Clearplayeranimation(playerid);
Sendclientmessage(Playerid, COLOR_RED, "Don't Ninja Jack your teammates"); //You need to define COLOR_RED to 0xAA3333FF, Or just replace It with another color, Or just put the hex directly
}
return 1;
}

Sting.
26/07/2017, 11:30 AM
Yea mate, I used GameTextForPlayer instead but thanks. +REP for looking out.

R4nd4ll
26/07/2017, 11:31 AM
Yea mate, I used GameTextForPlayer instead but thanks. +REP for looking out.

Thx, I will +Rep you back.

Btw, You can use both.
They would be awesome together.