Team score help!(rep+) + Veh save file!
#1

Hello,
First-
I tried to make Team Score's with Dini and failed to do so, I bugged my whole script. In the end i had to change it!
So i need to know that how can i Make a proper Team score thingy for gTeams funciton.

Team score is not equal to Team Kills. Its just a variable which saves in a txt file , loads up OnGameModeInIt and It increments(++) when a Team wins the Battle i.e. my public BattleWin(); Function.
Second-
I want to make a function to Load up all the saved vehicle's in a .txt file , The vehicle Function i use is CreateVehicle(); It should load more then 350 Vehicle's. You can use dini or anyway you do , Please help me to understand the code as well for future purpose!

If someone can help or tell me anything. Or code it for me, will be appreciable.
Will rep everyone who will help!

Thanks for reading
Char.C
Reply
#2

PHP код:
#include <a_samp>
new TEAM_1_SCORE 0TEAM_2_SCORE 0;
new 
gTeam[MAX_PLAYERS];
#define TEAM_1 0
#define TEAM_2 1
public OnPlayerDeath(playerid,killerid,reason)
{
    if(
killerid != INVALID_PLAYER_IDSetPlayerScore(killeridGetPlayerScore(killerid) + 1);
    switch(
gTeam[killerid])
    {
        case 
TEAM_1TEAM_1_SCORE++;
        case 
TEAM_2TEAM_2_SCORE++;
        default: return 
1;
    }
    return 
1;
}
public 
OnPlayerCommandText(playerid,cmdtext[])
{
    if(!
strcmp(cmdtext,"/teamscore",true))
    {
        new 
msg[128];
        switch(
gTeam[playerid])
        {
            case 
TEAM_1format(msg,128,"Your Team Score: %i",TEAM_1_SCORE);
            case 
TEAM_2format(msg,128,"Your Team Score: %i",TEAM_2_SCORE);
            default: return 
1;
        }
        
SendClientMessage(playerid,0xFF0000FF,msg);
        return 
1;
    }
    return 
0;

Try that.

-EDIT- Ups, you need something for vehicles as well. Try this one.

PHP код:
#include <a_samp>
#include <gl_common>
#define FILTERSCRIPT
#define CARS "cars.ini"
new bool:ValidVeh[MAX_VEHICLES] ;
public 
OnFilterScriptInit()
{
   
LoadStaticVehiclesFromFile(CARS);
   return 
1;
}
public 
OnFilterScriptExit()
{
    new 
fstring[288], Float:vXFloat:vYFloat:vZFloat:vAFile:veh;
    for(new 
0MAX_VEHICLESv++)
    {
        if(!
ValidVeh[v]) return 0;
        
GetVehiclePos(vvXvYvZ); GetVehicleZAngle(vvA);
        
format(fstring288"%d, %f, %f, %f, %f, -1, -1, -1;\r\n"GetVehicleModel(v), vXvYvZvA);
        
veh fopen(CARSio_append);
        
fwrite(vehfstring);
        
fclose(veh);
    }
    return 
1;
}
public 
OnVehicleSpawn(vehicleid)
{
    
ValidVeh[vehicleid] = true;
    return 
1;
}
public 
OnVehicleDeath(vehicleid)
{
    
ValidVeh[vehicleid] = false;
    return 
1;

NOTE: UNTESTED
Reply
#3

So you're adding score to the team of the person that just died?

EDIT:

pawn Код:
#include <a_samp>

new TEAM_1_SCORE = 0, TEAM_2_SCORE = 0;
new gTeam[MAX_PLAYERS];
#define TEAM_1 0
#define TEAM_2 1

public OnPlayerDeath(playerid,killerid,reason)
{
    if(killerid != INVALID_PLAYER_ID) SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    switch(gTeam[playerid])
    {
        case TEAM_1: TEAM_1_SCORE++;
        case TEAM_2: TEAM_2_SCORE++;
        default: return 1;
    }
    return 1;
}

public OnPlayerCommandText(playerid,cmdtext[])
{
    if(strcmp(cmdtext,"/teamscore",true) == 0)
    {
        new msg[128];
        switch(gTeam[playerid])
        {
            case TEAM_1: format(msg,128,"Your Team Score: %i",TEAM_1_SCORE);
            case TEAM_2: format(msg,128,"Your Team Score: %i",TEAM_2_SCORE);
            default: return 1;
        }
        SendClientMessage(playerid,0xFF0000FF,msg);
        return 1;
    }
    return 0;
}
Reply
#4

I already edited it...
Reply
#5

Quote:
Originally Posted by Mrki_Drakula
Посмотреть сообщение
I already edited it...
Nah I posted this before you even posted your vehicle code
Reply
#6

Oh...sorry then..
Reply
#7

What are you trying to do here?
pawn Код:
switch(gTeam[playerid])
    {
        case TEAM_1: TEAM_1_SCORE++;
        case TEAM_2: TEAM_2_SCORE++;
        default: return 1;
    }
Shouldn't this be:
pawn Код:
switch(gTeam[killerid])
    {
        case TEAM_1: TEAM_1_SCORE++;
        case TEAM_2: TEAM_2_SCORE++;
        default: return 1;
    }
Reply
#8

Quote:
Originally Posted by Mrki_Drakula
Посмотреть сообщение
PHP код:
public OnPlayerDeath(playerid,killerid,reason)
{
    if(
killerid != INVALID_PLAYER_IDSetPlayerScore(killeridGetPlayerScore(killerid) + 1);
    switch(
gTeam[playerid])
    {
        case 
TEAM_1TEAM_1_SCORE++;
        case 
TEAM_2TEAM_2_SCORE++;
        default: return 
1;
    }
    return 
1;

You're giving the score to the player that died.
Reply
#9

Oh i forgot to put killerid instead of playerid....i allways mix that two...lol..
Thanks guys.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)