SA-MP Forums Archive
GivePlayerWeapon - 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: GivePlayerWeapon (/showthread.php?tid=549782)



GivePlayerWeapon problems [+REP] - Jhony_Blaze - 08.12.2014

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.


Re: GivePlayerWeapon - Jhony_Blaze - 09.12.2014

No one can help ?


Re: GivePlayerWeapon - Threshold - 09.12.2014

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.


Re: GivePlayerWeapon - Jhony_Blaze - 09.12.2014

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)



Re: GivePlayerWeapon - Threshold - 09.12.2014

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

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


Re: GivePlayerWeapon - Jhony_Blaze - 09.12.2014

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
}



Re: GivePlayerWeapon - Threshold - 09.12.2014

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...
}



Re: GivePlayerWeapon - Jhony_Blaze - 09.12.2014

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;
		}



Re: GivePlayerWeapon - Jhony_Blaze - 09.12.2014

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 ?


Re: GivePlayerWeapon - Jhony_Blaze - 10.12.2014

Please people, help me out, whats the issue ?