PDA

View Full Version : The more score the more guns


Garc1a
09/10/2011, 08:04 PM
I'm using Zadmin and I need help because I want to make it so that if a player has 100 score, they have a certain gun, and if they have 200 score they have a certain gun etc.

I have no idea on how to do this so I hope you can help.

I know that Zadmin saves score.

Garc1a
10/10/2011, 06:54 AM
Underneath the OnPlayerSpawn callback, create something like:

switch(GetPlayerScore(playerid)) // Get the user's score for the switch.
{
case 0..5: GivePlayerWeapon(playerid, 24, 1000); // If the user's score is 0 -5, we'll give them a Desert Eagle. (1000 Ammo)
case 6..50: GivePlayerWeapon(playerid, 31, 1000); // If the user's score is 6 - 50, we'll give them an M4 carbine. (1000 Ammo)
case 51..9999: GivePlayerWeapon(playerid, 38, 1000); // If the user's score is 51 through 9999, we'll give them a Rotary Cannon. (1000 Ammo)
}


ZAdmin shouldn't matter as this is just getting the user's score.

wiki.sa-mp.com/wiki/Weapons <--- Weapon ID's.
wiki.sa-mp.com/wiki/Function:GivePlayerWeapon <--- GivePlayerWeapon function.
wiki.sa-mp.com/wiki/Control_Structures#switch_2 <--- Switch statement information.

How do I give them multiple guns?

Garc1a
10/10/2011, 03:25 PM
Bump

grand.Theft.Otto
10/10/2011, 03:32 PM
switch(GetPlayerScore(playerid)) // Get the user's score for the switch.
{
case 0..5:
{
GivePlayerWeapon(playerid, 24, 1000);
// multiple other weapons
// multiple other weapons
}
case 6..50:
{
GivePlayerWeapon(playerid, 31, 1000);
// multiple other weapons
// multiple other weapons
}
case 51..9999:
{
GivePlayerWeapon(playerid, 38, 1000);
// multiple other weapons
// multiple other weapons
}
return 1;
}

Garc1a
10/10/2011, 03:46 PM
switch(GetPlayerScore(playerid)) // Get the user's score for the switch.
{
case 0..5:
{
GivePlayerWeapon(playerid, 24, 1000);
// multiple other weapons
// multiple other weapons
}
case 6..50:
{
GivePlayerWeapon(playerid, 31, 1000);
// multiple other weapons
// multiple other weapons
}
case 51..9999:
{
GivePlayerWeapon(playerid, 38, 1000);
// multiple other weapons
// multiple other weapons
}
return 1;
}


Gives me this:

C:\Users\Johnny\Desktop\utdm - Copy - Copy - Copy\gamemodes\UTDM.pwn(349) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\Johnny\Desktop\utdm - Copy - Copy - Copy\gamemodes\UTDM.pwn(349) : warning 215: expression has no effect
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

grand.Theft.Otto
10/10/2011, 05:16 PM
Show me the line or part of code in your script where you're putting my block of code.

Laronic
10/10/2011, 05:18 PM
Gives me this:

C:\Users\Johnny\Desktop\utdm - Copy - Copy - Copy\gamemodes\UTDM.pwn(349) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\Johnny\Desktop\utdm - Copy - Copy - Copy\gamemodes\UTDM.pwn(349) : warning 215: expression has no effect
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

Try to remove the "return 1;" inside the switch

Garc1a
10/10/2011, 05:23 PM
I don't understand.. this is the code:

public OnPlayerSpawn(playerid)
{
SetPlayerToTeamColor(playerid);
switch(GetPlayerScore(playerid)) // Get the user's score for the switch.
{
case 0..5:
{
GivePlayerWeapon(playerid, 24, 1000);
// multiple other weapons
// multiple other weapons
}
case 6..50:
{
GivePlayerWeapon(playerid, 31, 1000);
// multiple other weapons
// multiple other weapons
}
case 51..9999:
{
GivePlayerWeapon(playerid, 38, 1000);
// multiple other weapons
// multiple other weapons
}
return 1;
}

The errors are coming from return 1;

Laronic
10/10/2011, 05:24 PM
public OnPlayerSpawn(playerid)
{
SetPlayerToTeamColor(playerid);
switch(GetPlayerScore(playerid)) // Get the user's score for the switch.
{
case 0..5:
{
GivePlayerWeapon(playerid, 24, 1000);
// multiple other weapons
// multiple other weapons
}
case 6..50:
{
GivePlayerWeapon(playerid, 31, 1000);
// multiple other weapons
// multiple other weapons
}
case 51..9999:
{
GivePlayerWeapon(playerid, 38, 1000);
// multiple other weapons
// multiple other weapons
}
}
return 1;
}

Garc1a
10/10/2011, 05:27 PM
public OnPlayerSpawn(playerid)
{
SetPlayerToTeamColor(playerid);
switch(GetPlayerScore(playerid)) // Get the user's score for the switch.
{
case 0..5:
{
GivePlayerWeapon(playerid, 24, 1000);
// multiple other weapons
// multiple other weapons
}
case 6..50:
{
GivePlayerWeapon(playerid, 31, 1000);
// multiple other weapons
// multiple other weapons
}
case 51..9999:
{
GivePlayerWeapon(playerid, 38, 1000);
// multiple other weapons
// multiple other weapons
}
}
return 1;
}


Ahaa, thanks, amazing how much one bracket can do.