SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 24/03/2010, 01:53 PM   #1
biltong
Gangsta
 
Join Date: Jan 2010
Posts: 546
Reputation: 0
Default Pvars...

Ok so I just tried to update my GM with the new PVar system, but in my team based GM, teams aren't being set at all.
pawn Code:
//at top of script
#define TEAM_COPS 1
#define TEAM_CRIMINALS 2
new Team[MAX_PLAYERS];

forward SetPlayerTeamFromClass(playerid, classid);
public SetPlayerTeamFromClass(playerid,classid) //called from OnPlayerRequestClass
{
    // Set their team number based on the class they selected.
    if(classid == 4 || classid == 5 || classid == 6 || classid == 7 || classid == 8 || classid == 9 || classid == 10 || classid == 11 || classid == 12)
    {
        SetPVarInt(playerid, Team, TEAM_COPS);
        SetPVarInt(playerid,HasPlayerChangedTeams,1);
        SetPVarInt(playerid,HasBeenSentObjectives,0);
    }
    else if(classid == 0 || classid == 1 || classid == 2 || classid == 3)
    {
      SetPVarInt(playerid, Team, TEAM_CRIMINALS);
      SetPVarInt(playerid,HasPlayerChangedTeams,1);
      SetPVarInt(playerid,HasBeenSentObjectives,0);
    }
    return 1;
}

public SetPlayerToTeamColor(playerid) //called from OnPlayerSpawn, which also checks for team
{
    if(GetPVarInt(playerid,Team) == TEAM_COPS)  SetPlayerColor(playerid,COPS_COLOR); // blue
    else if(GetPVarInt(playerid,Team) == TEAM_CRIMINALS) SetPlayerColor(playerid,CRIMINALS_COLOR); // red
    return 1;
}

Nothing works. I set every player who connects colour to white when they connect, then set their color based on their team when they spawn.
Did I use PVars wrong?

EDIT: why is everything in there blue?
__________________
My releases:
[FS]Admin Click - An admin shortcut script. Lots of commands like kick and ban in a few mouse clicks!
[FS]Vehicle Names - Simple script that displays your vehicle's name whenever you enter one.
[GM]Cops 'n Criminals - An unusual TDM.


Not active anymore, PM me if necessary.
biltong is offline  
Old 24/03/2010, 03:30 PM   #2
Anwix
Big Clucker
 
Anwix's Avatar
 
Join Date: Jun 2007
Posts: 130
Reputation: 0
Default Re: Pvars...

Try this:

pawn Code:
//at top of script
#define TEAM_COPS 1
#define TEAM_CRIMINALS 2
new Team[MAX_PLAYERS];

forward SetPlayerTeamFromClass(playerid, classid);
public SetPlayerTeamFromClass(playerid, classid) //called from OnPlayerRequestClass
{
    // Set their team number based on the class they selected.
    if (classid == 4 || classid == 5 || classid == 6 || classid == 7 || classid == 8 || classid == 9 || classid == 10 || classid == 11 || classid == 12)
    {
        SetPVarInt(playerid, Team[playerid], TEAM_COPS);
        SetPVarInt(playerid, HasPlayerChangedTeams, 1);
        SetPVarInt(playerid, HasBeenSentObjectives, 0);
    }
    else if (classid == 0 || classid == 1 || classid == 2 || classid == 3)
    {
      SetPVarInt(playerid, Team[playerid], TEAM_CRIMINALS);
      SetPVarInt(playerid, HasPlayerChangedTeams, 1);
      SetPVarInt(playerid, HasBeenSentObjectives, 0);
    }
    return 1;
}

public SetPlayerToTeamColor(playerid) //called from OnPlayerSpawn, which also checks for team
{
    if (GetPVarInt(playerid, Team[playerid]) == TEAM_COPS) SetPlayerColor(playerid,COPS_COLOR); // blue
    else if (GetPVarInt(playerid, Team[playerid]) == TEAM_CRIMINALS) SetPlayerColor(playerid,CRIMINALS_COLOR); // red
    return 1;
}

Untested.
Anwix is offline  
Old 24/03/2010, 04:10 PM   #3
biltong
Gangsta
 
Join Date: Jan 2010
Posts: 546
Reputation: 0
Default Re: Pvars...

Still doesn't work. I think I have tracked the issue down to actually setting the player's teams. I tried using 1 and 2 instead of TEAM_COPS and TEAM_CRIMINALS but that also didn't work. Each player that joins is getting their team set to 0 which is undefined in my GM.
__________________
My releases:
[FS]Admin Click - An admin shortcut script. Lots of commands like kick and ban in a few mouse clicks!
[FS]Vehicle Names - Simple script that displays your vehicle's name whenever you enter one.
[GM]Cops 'n Criminals - An unusual TDM.


Not active anymore, PM me if necessary.
biltong is offline  
Old 25/03/2010, 03:14 PM   #4
biltong
Gangsta
 
Join Date: Jan 2010
Posts: 546
Reputation: 0
Default Re: Pvars...

Bump. Can someone please show me the proper way to use these? <3
__________________
My releases:
[FS]Admin Click - An admin shortcut script. Lots of commands like kick and ban in a few mouse clicks!
[FS]Vehicle Names - Simple script that displays your vehicle's name whenever you enter one.
[GM]Cops 'n Criminals - An unusual TDM.


Not active anymore, PM me if necessary.
biltong is offline  
Old 25/03/2010, 03:18 PM   #5
Anwix
Big Clucker
 
Anwix's Avatar
 
Join Date: Jun 2007
Posts: 130
Reputation: 0
Default Re: Pvars...

Just realised what i did wrong.

Try this:

pawn Code:
//at top of script
#define TEAM_COPS 1
#define TEAM_CRIMINALS 2

forward SetPlayerTeamFromClass(playerid, classid);
public SetPlayerTeamFromClass(playerid, classid) //called from OnPlayerRequestClass
{
    // Set their team number based on the class they selected.
    if (classid == 4 || classid == 5 || classid == 6 || classid == 7 || classid == 8 || classid == 9 || classid == 10 || classid == 11 || classid == 12)
    {
        SetPVarInt(playerid, "Team", TEAM_COPS);
        SetPVarInt(playerid, "HasPlayerChangedTeams", 1);
        SetPVarInt(playerid, "HasBeenSentObjectives", 0);
    }
    else if (classid == 0 || classid == 1 || classid == 2 || classid == 3)
    {
      SetPVarInt(playerid, "Team", TEAM_CRIMINALS);
      SetPVarInt(playerid, "HasPlayerChangedTeams", 1);
      SetPVarInt(playerid, "HasBeenSentObjectives", 0);
    }
    return 1;
}

public SetPlayerToTeamColor(playerid) //called from OnPlayerSpawn, which also checks for team
{
    if (GetPVarInt(playerid, "Team") == TEAM_COPS) SetPlayerColor(playerid,COPS_COLOR); // blue
    else if (GetPVarInt(playerid, "Team") == TEAM_CRIMINALS) SetPlayerColor(playerid,CRIMINALS_COLOR); // red
    return 1;
}
Anwix is offline  
Old 25/03/2010, 03:30 PM   #6
biltong
Gangsta
 
Join Date: Jan 2010
Posts: 546
Reputation: 0
Default Re: Pvars...

Will try now.
EDIT: By doing that I get unused warnings. Must I still create the variables?
EDIT EDIT: Got rid of the variables and it still compiled, though now for some reason you get set to TEAM_COPS regardless of whether your "Team" is set to TEAM_COPS or TEAM_CRIMINALS
__________________
My releases:
[FS]Admin Click - An admin shortcut script. Lots of commands like kick and ban in a few mouse clicks!
[FS]Vehicle Names - Simple script that displays your vehicle's name whenever you enter one.
[GM]Cops 'n Criminals - An unusual TDM.


Not active anymore, PM me if necessary.
biltong is offline  
Old 25/03/2010, 03:44 PM   #7
Anwix
Big Clucker
 
Anwix's Avatar
 
Join Date: Jun 2007
Posts: 130
Reputation: 0
Default Re: Pvars...

Could you post the warnings please
Anwix is offline  
Old 25/03/2010, 04:03 PM   #8
biltong
Gangsta
 
Join Date: Jan 2010
Posts: 546
Reputation: 0
Default Re: Pvars...

This is really confusing. Now I actually get set to a team, but regardless of which class I choose I get set to team 1 which is the cops. Yet I have a function that doesn't let you in a hunter if you're not a cop, and it's not letting me in a hunter ??

I thought maybe it didn't like "TEAM_COPS" and "TEAM_CRIMINALS" but it doesn't seem to be that, since I changed the thing that sets your team to SetPVarInt(playerid,"Team",1); for cops and SetPVarInt(playerid,"Team",2); for criminals but I still get set to team 1 regardless of anything I do. :/

EDIT: I made a cmd showing all the PVars I use, and each one is still being set to 0
__________________
My releases:
[FS]Admin Click - An admin shortcut script. Lots of commands like kick and ban in a few mouse clicks!
[FS]Vehicle Names - Simple script that displays your vehicle's name whenever you enter one.
[GM]Cops 'n Criminals - An unusual TDM.


Not active anymore, PM me if necessary.
biltong is offline  
Old 26/03/2010, 01:31 PM   #9
biltong
Gangsta
 
Join Date: Jan 2010
Posts: 546
Reputation: 0
Default Re: Pvars...

Bump, I redownloaded the server (Windows R5-2), still have same issue. Also, this:
pawn Code:
AddPlayerClass(29,1930.8324,740.1257,10.8203,179.3071,28,300,35,2,0,0); // crims_spawn1
    AddPlayerClass(0,1930.8324,740.1257,10.8203,179.3071,28,300,35,2,0,0); // crims_spawn1
    AddPlayerClass(179,1930.8324,740.1257,10.8203,179.3071,28,300,35,2,0,0); // crims_spawn1
    AddPlayerClass(124,1930.8324,740.1257,10.8203,179.3071,28,300,35,2,0,0); // crims_spawn1

    for(id = 280; id <= 288; id++)
    {
        AddPlayerClass(id,340.0815,2026.1152,22.6406,99.1120,24,70,0,0,0,0); // cops_spawn
    }
gives me all those weapons regardless of what class I choose. Sometimes it even gives me double or triple the ammo!
__________________
My releases:
[FS]Admin Click - An admin shortcut script. Lots of commands like kick and ban in a few mouse clicks!
[FS]Vehicle Names - Simple script that displays your vehicle's name whenever you enter one.
[GM]Cops 'n Criminals - An unusual TDM.


Not active anymore, PM me if necessary.
biltong is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] to pvars russo666 Help Archive 5 31/05/2010 09:28 PM
Pvars Steven82 Help Archive 0 26/05/2010 08:52 PM
Looping Pvars Dark_Kostas Help Archive 4 06/04/2010 07:18 AM
PVars Question(s) XGh0stz Help Archive 0 02/04/2010 08:08 PM
Pvars question? Torran Help Archive 4 26/03/2010 05:53 PM


All times are GMT. The time now is 09:42 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.