SA-MP Forums Archive
some one fix that please - 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: some one fix that please (/showthread.php?tid=311072)



some one fix that please - BlacKxStory - 15.01.2012

i want to if you entred in the zone (in pawno) you captured
some one help me please
becuase if i entred in the zone she is no't work help please

Quote:

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

main()
{
print("\n----------------------------------");
print(" MoustahSsen BlacKxOps");
print("----------------------------------\n");
}

#include <dini>
#include <dudb>
#include <gl_common>
#include <foreach>
#include <a_zones>

#define TEAM_Latino 1
#define TEAM_Souviet 2
#define TEAM_Arabian 3
#define TEAM_USA 4
#define TEAM_Europian 5
#define TEAM_Japan 6
#define TEAM_Taliban 7

#define TEAM_Latino_COLOR 0x00F3FFAF
#define TEAM_Souviet_COLOR 0xCA0000FF
#define TEAM_Arabian_COLOR 0xD70000FF
#define TEAM_USA_COLOR 0x1400C3FF
#define TEAM_Europian_COLOR 0x005E0089
#define TEAM_Japan_COLOR 0xFAFAFFFF
#define TEAM_Taliban_COLOR 0xFFFFFFFF




new gTeam[MAX_PLAYERS];
new EnteredArea5[MAX_PLAYERS];




new CapturedBy1; // 0 ( none ) 1 ( USA ) 2 ( Germany )

new T1[MAX_PLAYERS];
new IfCapture[2];
new uscore;
new gscore;
new A;
new AU;
new AG;








public AreaCheck()
{
foreach(Player, i)
{
if(IsPlayerInArea(i ,105.1009, 1775.037, 373.692, 1950.205))
{
if(EnteredArea5[i] == 0) // if he hasn't entered before
{
if(gTeam[i] == TEAM_USA && CapturedBy1 == 1 || gTeam[i] == TEAM_Japan && CapturedBy1 == 2 || gTeam[i] == TEAM_Japan && CapturedBy1 == 3 || gTeam[i] == TEAM_USA && CapturedBy1 == 4)
{
SendClientMessage(i,0x23FF00FF, "This area has already been captured by your team!");
EnteredArea5[i] = 1;
}
else
{
EnteredArea5[i] = 1; // He has entered
SendClientMessage(i,0x23FF00FF, "Stay In here for 30 seconds to take over the area!");
T1[i] = SetTimer("TakeOver",30000,0);
SendClientMessageToAll(0x23FF00FF, "Area 69 is being taken over!");
}
}
}
else
{
EnteredArea5[i] = 0; // When he leaves, he's no longer in the area
KillTimer(T1[i]);
}
}
return 1;
}

public TakeOver()
{
foreach(Player, i)
{
if(IsPlayerInArea(i, 1105.1009, 1775.037, 373.692, 1950.205) && gTeam[i] == TEAM_USA)
{
if(CapturedBy1 != 1)
{
if( IfCapture[1] == 1 ) return 1;
IfCapture[1] = 0;
dini_IntSet("/Variables/Variables.ini", "CapturedBy1", 1);
//SetTimer("ScoreText", 5000, 0);
uscore++;
SetPlayerScore(i, GetPlayerScore(i) + 2);
CapturedBy1 = 1;
if(CapturedBy1 != 2)SendClientMessageToAll(0xEBFF00FF, "NEWS: Team USA have captured area 69!");
GangZoneHideForAll(A);
GangZoneShowForAll(AU, 0xFF00C3FF);
GangZoneHideForAll(AG);
dini_IntSet("/scriptfiles/Variables/Variables.ini", "uscore", uscore);

}
}
else if(IsPlayerInArea(i, 105.1009, 1775.037, 373.692, 1950.205) && gTeam[i] == TEAM_Japan)
{
if(CapturedBy1 != 2)
{
if( IfCapture[1] == 1 ) return 1;
IfCapture[1] = 0;
dini_IntSet("/Variables/Variables.ini", "CapturedBy5", 2);
gscore++;
//SetTimer("ScoreText", 5000, 0);
SetPlayerScore(i, GetPlayerScore(i) + 2);
CapturedBy1 = 2;
if(CapturedBy1 != 1)SendClientMessageToAll(0xEBFF00FF, "NEWS: Team GERMANY have captured area 69!");
GangZoneHideForAll(A);
GangZoneShowForAll(AG, 0xFF00C3FF);
GangZoneHideForAll(AU);
dini_IntSet("/Variables/Variables.ini", "gscore", gscore);

}
}
}
return 1;
}

public OnGameModeInit()
{
UsePlayerPedAnims();

AddPlayerClass(108,1091.8289,1892.5746,10.8203,181 .3648,0,0,0,0,0,0); //Latino (0)
AddPlayerClass(206,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Souviet (1)
AddPlayerClass(179,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Arabian(2)
AddPlayerClass(287,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //USA (3)
AddPlayerClass(285,-148.1873,1142.0114,19.7422,16.0408,0,0,0,0,0,0); //Europian(4)
AddPlayerClass(188,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Japan (5).
AddPlayerClass(163,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Taliban(6)
SetGameModeText("Blank Script");
return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid,1984.4445,157.9501,55.9384);
SetPlayerCameraPos(playerid,1984.4445,160.9501,55. 9384);
SetPlayerCameraLookAt(playerid,1984.4445,157.9501, 55.9384);
SetPlayerTeamFromClass(playerid, classid);
return 1;
}

public OnPlayerConnect(playerid)
{
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
return 1;
}

public OnPlayerSpawn(playerid)
{
SetPlayerToTeamColor(playerid);
return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
if (classid == 0)
{
gTeam[playerid] = TEAM_Latino;
}
else if (classid == 1)
{
gTeam[playerid] = TEAM_Souviet;
}
else if (classid == 2)
{
gTeam[playerid] = TEAM_Arabian;
}
else if (classid == 3)
{
gTeam[playerid] = TEAM_USA;
}
else if (classid == 4)
{
gTeam[playerid] = TEAM_Europian;
}
else if (classid == 5)
{
gTeam[playerid] = TEAM_Japan;
}
else if (classid == 6)
{
gTeam[playerid] = TEAM_Taliban;
}
}



SetPlayerToTeamColor(playerid)
{
if (gTeam[playerid] == TEAM_Latino)
{
SetPlayerColor(playerid, TEAM_Latino_COLOR);
}
else if (gTeam[playerid] == TEAM_Souviet)
{
SetPlayerColor(playerid, TEAM_Souviet_COLOR);
}

else if (gTeam[playerid] == TEAM_Arabian)
{
SetPlayerColor(playerid, TEAM_Arabian_COLOR);
}

else if (gTeam[playerid] == TEAM_USA)
{
SetPlayerColor(playerid, TEAM_USA_COLOR);
}

else if (gTeam[playerid] == TEAM_Europian)
{
SetPlayerColor(playerid, TEAM_Europian_COLOR);
}

else if (gTeam[playerid] == TEAM_Japan)
{
SetPlayerColor(playerid, TEAM_Japan_COLOR);
}
else if (gTeam[playerid] == TEAM_Taliban)
{
SetPlayerColor(playerid, TEAM_Taliban_COLOR);
}
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}

public OnRconCommand(cmd[])
{
return 1;
}

public OnPlayerRequestSpawn(playerid)
{
return 1;
}

public OnObjectMoved(objectid)
{
return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}

public OnPlayerExitedMenu(playerid)
{
return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}

public OnPlayerUpdate(playerid)
{
return 1;
}

stock IsPlayerInArea(playerid,Float:min_x,Float:min_y,Fl oat:max_x,Float:max_y)
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X, Y, Z);
if((X <= max_x && X >= min_x) && (Y <= max_y && Y >= min_y)) return 1;

return 0;
}


public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}




Re: some one fix that please - coole210 - 15.01.2012

I spent quite some time fixing up your code and understanding your problem.

pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

main()
{
print("\n----------------------------------");
print(" MoustahSsen BlacKxOps");
print("----------------------------------\n");
}

#include <dini>
#include <dudb>
#include <foreach>

#pragma unused ret_memcpy

#define MAX_TEAMS 7
#define TEAM_Latino 1
#define TEAM_Souviet 2
#define TEAM_Arabian 3
#define TEAM_USA 4
#define TEAM_Europian 5
#define TEAM_Japan 6
#define TEAM_Taliban 7

#define TEAM_Latino_COLOR 0x00F3FFAF
#define TEAM_Souviet_COLOR 0xCA0000FF
#define TEAM_Arabian_COLOR 0xD70000FF
#define TEAM_USA_COLOR 0x1400C3FF
#define TEAM_Europian_COLOR 0x005E0089
#define TEAM_Japan_COLOR 0xFAFAFFFF
#define TEAM_Taliban_COLOR 0xFFFFFFFF

new TeamNames[][] = {
{ "Latino" },
{ "Souviet" },
{ "Arabian" },
{ "USA" },
{ "Europian" },
{ "Japan" },
{ "Taliban" }
};
forward AreaCheck();
forward TakeOver(playerid);
new gTeam[MAX_PLAYERS];
new EnteredArea[MAX_PLAYERS]=-1;
new Captured;
new Score[MAX_TEAMS];
new T1[MAX_PLAYERS];
new A;
new AU;
new AG;

public OnGameModeInit()
{
    UsePlayerPedAnims();
    AddPlayerClass(108,1091.8289,1892.5746,10.8203,181.3648,0,0,0,0,0,0); //Latino (0)
    AddPlayerClass(206,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Souviet (1)
    AddPlayerClass(179,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Arabian(2)
    AddPlayerClass(287,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //USA (3)
    AddPlayerClass(285,-148.1873,1142.0114,19.7422,16.0408,0,0,0,0,0,0); //Europian(4)
    AddPlayerClass(188,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Japan (5).
    AddPlayerClass(163,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //Taliban(6)
    SetGameModeText("Blank Script");
    SetTimer("CheckArea",1000,true);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid,1984.4445,157.9501,55.9384);
    SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384);
    SetPlayerCameraLookAt(playerid,1984.4445,157.9501, 55.9384);
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

public OnPlayerConnect(playerid)
{
    EnteredArea[playerid]=-1;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    KillTimer(T1[playerid]);
    EnteredArea[playerid]=-1;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColor(playerid);
    return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
    gTeam[playerid] = classid+1;
}

SetPlayerToTeamColor(playerid)
{
    if (gTeam[playerid] == TEAM_Latino)
    {
        SetPlayerColor(playerid, TEAM_Latino_COLOR);
    }
    else if (gTeam[playerid] == TEAM_Souviet)
    {
        SetPlayerColor(playerid, TEAM_Souviet_COLOR);
    }
    else if (gTeam[playerid] == TEAM_Arabian)
    {
        SetPlayerColor(playerid, TEAM_Arabian_COLOR);
    }
    else if (gTeam[playerid] == TEAM_USA)
    {
        SetPlayerColor(playerid, TEAM_USA_COLOR);
    }
    else if (gTeam[playerid] == TEAM_Europian)
    {
        SetPlayerColor(playerid, TEAM_Europian_COLOR);
    }
    else if (gTeam[playerid] == TEAM_Japan)
    {
        SetPlayerColor(playerid, TEAM_Japan_COLOR);
    }
    else if (gTeam[playerid] == TEAM_Taliban)
    {
        SetPlayerColor(playerid, TEAM_Taliban_COLOR);
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

stock IsPlayerInArea(playerid,Float:min_x,Float:min_y,Float:max_x,Float:max_y)
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if((X <= max_x && X >= min_x) && (Y <= max_y && Y >= min_y)) return 1;
    return 0;
}


public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
public AreaCheck()
{
    foreach(Player, i)
    {
        if(IsPlayerInArea(i, 105.1009, 1775.037, 373.692, 1950.205))
        {
            if(EnteredArea[i] != 5)
            {
                if(Captured == gTeam[i])
                {
                    SendClientMessage(i,0x23FF00FF, "This area has already been captured by your team!");
                    EnteredArea[i] = 5;
                }
                else
                {
                    KillTimer(T1[i]);
                    EnteredArea[i] = 5;
                    SendClientMessage(i,0x23FF00FF, "Stay In here for 30 seconds to take over the area!");
                    T1[i] = SetTimerEx("TakeOver",30000,false,"i",i);
                    SendClientMessageToAll(0x23FF00FF, "Area 69 is being taken over!");
                }
            }
            else
            {
                EnteredArea[i] = 0;
                KillTimer(T1[i]);
            }
        }
    }
    return 1;
}

public TakeOver(playerid)
{
    new string[128],string2[64];
    if(EnteredArea[playerid] == 5)
    {
        if(Captured == gTeam[playerid]) return 1;
        SetPlayerScore(playerid,GetPlayerScore(playerid)+2);
        Score[gTeam[playerid]-1]++;
        format(string,sizeof(string),"NEWS: Team %s has captured area 69!",TeamNames[gTeam[playerid]-1]);
        SendClientMessageToAll(0xEBFF00FF,string);
        format(string2,sizeof(string2),"gTeam%dScore",gTeam[playerid]);
        dini_IntSet("/Variables/Variables.ini",string,Score[gTeam[playerid]-1]);
        GangZoneHideForAll(A);
        GangZoneShowForAll(AU, 0xFF00C3FF);
        GangZoneHideForAll(AG);
        Captured = gTeam[playerid];
    }
    return 1;
}
You should read everything documented in http://wiki.sa-mp.com.

Rep