01.04.2013, 22:48
Hi guys, i have few questions about pickups, team and classes.
Alright, here i describe what i have to do:
i have a GM that manage Teams like USA and Russia, and classes like Recon, Support, Medic ecc...
Every Team has the same classes, so i want that the medic class, when it hits the middle mouse button creates a Medikit, that's the hearth pickup icon, and lock that pickup, if the Medic is in Team USA then only players in Team USA can pickup it, else if the medic is in Team Russia only russian can pickup it. Now i thought to use an Array list of all the Medikit created by USA team and Russia team, and when an american medic create a new medikit, the old one get destroyed. Ok now all teams and classes are setted up the right way BUT...when i'm USA team and i create a medikit then the medikit appears, and when i lose health and pick it up, it destroy itself, and here comes the annoing things.
1-Other players can still see the pickup, no matter if for me is destroyed, they can still see it;
2-Russia Team's players can pick up USA Team's pickup;
Here is the parts of the code that manage this thing:
At the top i added this:
then For the key detection :
And last part is for when a player pick up the pickup :
I hope that you guys can help me, i'm stuck at this point for 2 days and my server isn't proceding as i was hoping, so any help is appreciated.
Thanks in advance
RebelWolf
Alright, here i describe what i have to do:
i have a GM that manage Teams like USA and Russia, and classes like Recon, Support, Medic ecc...
Every Team has the same classes, so i want that the medic class, when it hits the middle mouse button creates a Medikit, that's the hearth pickup icon, and lock that pickup, if the Medic is in Team USA then only players in Team USA can pickup it, else if the medic is in Team Russia only russian can pickup it. Now i thought to use an Array list of all the Medikit created by USA team and Russia team, and when an american medic create a new medikit, the old one get destroyed. Ok now all teams and classes are setted up the right way BUT...when i'm USA team and i create a medikit then the medikit appears, and when i lose health and pick it up, it destroy itself, and here comes the annoing things.
1-Other players can still see the pickup, no matter if for me is destroyed, they can still see it;
2-Russia Team's players can pick up USA Team's pickup;
Here is the parts of the code that manage this thing:
At the top i added this:
Код:
new Medikit[MAX_PLAYERS]; new MedikitTeam[MAX_OBJECTS];
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION)) { new Float:PlayerPos[3]; GetPlayerPos(playerid,PlayerPos[0],PlayerPos[1],PlayerPos[2]); if(GetPlayerState(playerid) == 1) { if(playerClass[playerid] == TeamClassType[Medic]) //Is a Medic Class { if(gTeam[playerid] == 1) { if(Medikit[playerid] == 0) { Medikit[0] = CreatePickup(1240,3,PlayerPos[0],PlayerPos[1]-2,PlayerPos[2],-1); MedikitTeam[Medikit[0]] = 1; return 1; } else if(Medikit[playerid] > 0) { DestroyObject(Medikit[0]); Medikit[0] = CreatePickup(1240,3,PlayerPos[0],PlayerPos[1]-2,PlayerPos[2],-1); MedikitTeam[Medikit[0]] = 1; return 1; } } else if(gTeam[playerid] == 2) { if(Medikit[playerid] == 0) { Medikit[0] = CreatePickup(1240,3,PlayerPos[0],PlayerPos[1]-2,PlayerPos[2],-1); MedikitTeam[Medikit[0]] = 2; return 1; } else if(Medikit[playerid] > 0) { DestroyObject(Medikit[1]); Medikit[0] = CreatePickup(1240,3,PlayerPos[0],PlayerPos[1]-2,PlayerPos[2],-1); MedikitTeam[Medikit[0]] = 2; return 1; } } } } } return 1;
Код:
public OnPlayerPickUpPickup(playerid, pickupid) { if(pickupid == Medikit[playerid]) { if(gTeam[playerid] == MedikitTeam[Medikit[0]]) { SetPlayerHealth(playerid,100); DestroyObject(Medikit[0]); return 1; } } return 1; }
Thanks in advance
RebelWolf