GivePlayerWeapon
#1

So I have a struggle with this, I want to give weapon to a specific class. Weapons appear perfectly for police class but for mafia class they won't show up.



Here are the defines:

PHP код:
new bool:PoliceGetsWeapons true;
new 
bool:MafiaGetsWeapons true;
new 
APoliceWeapons[4] = {24253129};
new 
PoliceWeaponsAmmo 5000;
new 
AMafiaWeapons[3] = {223032};
new 
MafiaWeaponsAmmo 5000

This is the command under police class:

PHP код:
        case ClassPolice// Police class
        
{
            
format(missiontextsizeof(missiontext), Police_NoJobText); // Preset the missiontext
            
SetPlayerColor(playeridColorClassPolice); // Set the playercolor (chatcolor for the player and color on the map)
            // Start the PlayerCheckTimer to scan <a href="http://cityadspix.com/tsclick-BQBE4NPP-VRMIQUYF?url=http%3A%2F%2Fwww.enter.ru%2Fproduct%2Felectronics%2Figra-dlya-ps-vita-need-for-speed-most-wanted-2060401013472&sa=mh&sa1=&sa2=&sa3=&sa4=&sa5=&bt=20&pt=9&lt=2&tl=3&im=Mjc3NS0wLTE0MTgxMjM1ODYtMTQ3Njg5MDg%3D&fid=NDQ1NzU2Nzc1&prdct=023008390e390c3206&kw=for%20wanted" target="_blank" alt="Need for Speed: Most Wanted" title="Need for Speed: Most Wanted" style="">for wanted</a> players (be sure the timer has been destroyed first)
            
KillTimer(APlayerData[playerid][PlayerCheckTimer]);
            
APlayerData[playerid][PlayerCheckTimer] = SetTimerEx("Police_CheckWantedPlayers"1000true"i"playerid);
            
// Check if the police player can get weapons
            
if (PoliceGetsWeapons == true)
            {
                
// Give up to 12 weapons to the player
                
for (new i4i++)
                    
GivePlayerWeapon(playeridAPoliceWeapons[i], PoliceWeaponsAmmo);
            }
        } 
This is the command under mafia class:

PHP код:
        case ClassMafia// Mafia class
        
{
            
format(missiontextsizeof(missiontext), Mafia_NoJobText); // Preset the missiontext
            
SetPlayerColor(playeridColorClassMafia); // Set the playercolor (chatcolor for the player and color on the map)
            // Start the PlayerCheckTimer to scan for players that carry mafia-loads (be sure the timer has been destroyed first)
            
KillTimer(APlayerData[playerid][PlayerCheckTimer]);
            
APlayerData[playerid][PlayerCheckTimer] = SetTimerEx("Mafia_CheckMafiaLoads"1000true"i"playerid);
            
// Check if the mafia player can get weapons
            
if (MafiaGetsWeapons == true)
            {
                
// Give up to 12 weapons to the player
                
for (new i3i++)
                    
GivePlayerWeapon(playeridAMafiaWeapons[i], MafiaWeaponsAmmo);
            }
        } 
I honestly, can't see any issue, gamemode compiles alright too.
Reply
#2

No one can help ?
Reply
#3

Can you show the full callback, or at least the full switch statement that you're using ClassMafia and ClassPolice in? And if possible, where you define ClassMafia and ClassPolice.
Reply
#4

Here is the define

Код:
#define ClassPolice 4
#define ClassMafia 5
Other then then I don't really have nothing else, only few stuff under:

Код:
public OnPlayerRequestSpawn(playerid)
And some other stuff under:

Код:
public OnPlayerRequestClass(playerid, classid)
Reply
#5

I assume you're doing: "switch(classid)" ?

If yes, please show your OnGameModeInit where you add your 'AddPlayerClass' lines.
Reply
#6

Here are all the classes

Код:
GameModeInit_Classes()
{
	AddPlayerClass(133, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 0 = Truck driver
	AddPlayerClass(201, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 1 = Truck driver
	AddPlayerClass(202, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 2 = Truck driver
	AddPlayerClass(234, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 3 = Truck driver
	AddPlayerClass(258, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 4 = Truck driver
	AddPlayerClass(261, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 5 = Truck driver
	AddPlayerClass(206, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 6 = Truck driver
	AddPlayerClass(34, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 7 = Truck driver

	AddPlayerClass(255, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 8 = Bus driver
	AddPlayerClass(253, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 9 = Bus driver

	AddPlayerClass(61, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 10 = Pilot

	AddPlayerClass(280, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 11 = Police
	AddPlayerClass(282, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 12 = Police
	AddPlayerClass(283, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 13 = Police

	AddPlayerClass(111, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 14 = Mafia
	AddPlayerClass(112, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 15 = Mafia
	AddPlayerClass(113, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 16 = Mafia

	AddPlayerClass(250, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 17 = Courier
	AddPlayerClass(193, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 18 = Courier

	AddPlayerClass(50, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 19 = Assistance

	AddPlayerClass(16, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 20 = Roadworker
	AddPlayerClass(27, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 21 = Roadworker
	AddPlayerClass(260, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // Class 22 = Roadworker
}
Reply
#7

There's your issue...
pawn Код:
#define ClassPolice 4
#define ClassMafia 5
Class 4 is a Truck Driver.
Class 5 is also a Truck Driver.

Rather than having 'case ClassPolice' and 'case ClassMafia', have:
pawn Код:
case 11 .. 13:
{
    //Police stuff...
}
case 14 .. 16:
{
    //Mafia stuff...
}
Reply
#8

Doesn't really make any difference, I did what you told me to do. Mafia still wont get the guns but Police Class gets them.

Here are all the Classes defined

Код:
// Define classes
#define ClassTruckDriver 1
#define ClassBusDriver 2
#define ClassPilot 3
#define ClassPolice 4
#define ClassMafia 5
#define ClassCourier 6
#define ClassAssistance 7
#define ClassRoadWorker 8
Here are the classes under
PHP код:
public OnPlayerRequestClass(playeridclassid
Код:
		case 11, 12, 13: // Classes that will be police
		{
			// Display the name of the class
            GameTextForPlayer(playerid, TXT_ClassPolice, 3000, 4);
			// Store the class for the player (police)
			APlayerData[playerid][PlayerClass] = ClassPolice;
		}
		case 14, 15, 16: // Classes that will be mafia
		{
			// Display the name of the class
			GameTextForPlayer(playerid, TXT_ClassMafia, 3000, 4);
			// Store the class for the player (mafia)
			APlayerData[playerid][PlayerClass] = ClassMafia;
		}
Reply
#9

So? I still didn't fixed this? Why it won't work if everything looks fine... Why do the police class gets the guns but mafia class doesn't ?
Reply
#10

Please people, help me out, whats the issue ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)