Szerző Téma: 1 Probléma  (Megtekintve 1005 alkalommal)

Nem elérhető Buba

  • 540
    • Profil megtekintése
1 Probléma
« Dátum: 2011. Április 30. - 18:43:58 »
0 Show voters
hali!
Egy versenyt akarnék csinálni csak nem sikerül.
A hiba hogy az elsõ CP után azt írja ki, hogy a verseny végére értél.
Gondolom hogy ahogy bemegy az elsõbe lefut az összes többi utasítás is. Hogy tudom kijavítani?
Elõre is köszönöm.
Ja és a script:
[pawn]#include <a_samp>
#include <zcmd>
new checkpoints[18];
new cel;
CMD:race(playerid,params[])
{
sPlayerPos(playerid,2045.7445,1360.8739,10.2429,0,0);
SetPlayerCheckpoint(playerid,2047.3328,1111.7773,10.2429,8.5);
SetPVarInt(playerid,\"CP\",checkpoints[0]);
        return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(GetPVarInt(playerid,\"CP\") == checkpoints[0])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2015.4202,847.9307,6.2977,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[1]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[1])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1791.1125,817.5202,10.3641,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[2]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[2])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1631.8530,216.9445,30.7127,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[3]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[3])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1701.1248,-636.8368,40.6468,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[4]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[4])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1576.2233,-1413.4781,28.0421,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[5]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[5])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1693.2444,-1543.3309,23.1510,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[6]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[6])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2113.5508,-1537.3674,2.0323,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[7]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[7])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2720.7590,-1629.2537,12.4153,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[8]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[8])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2890.6548,-1621.0668,10.4455,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[9]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[9])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2894.3796,-935.4986,10.4460,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[10]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[10])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2752.1931,-371.6379,24.4416,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[11]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[11])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2776.1350,191.8326,19.8359,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[12]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[12])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1704.2252,397.0681,29.9643,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[13]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[13])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1825.7363,837.4744,9.9731,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[14]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[14])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2070.1272,867.7535,6.4078,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[15]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[15])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2086.0061,1373.9753,10.2429,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[16]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[16])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2159.8550,1428.2513,10.3912,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[17]);
}
if(GetPVarInt(playerid,\"CP\") == checkpoints[17])
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2247.2556,1465.3269,10.2428,8.5);
    SetPVarInt(playerid,\"CP\",checkpoints[17]);
}
if(GetPVarInt(playerid,\"CP\") == cel)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2306.2717,1494.6664,10.3943,8.5);
    DisablePlayerCheckpoint(playerid);
    SendClientMessage(playerid,COLOR_LIGHTGREEN,\"A verseny végére értél!\");
}
return 1;
}[/pawn]
Errort, Warningot nem jelez.

Nem elérhető Stray

  • 617
    • Profil megtekintése
1 Probléma
« Válasz #1 Dátum: 2011. Április 30. - 18:52:24 »
0 Show voters
Hello. Nem tudom minek deklaráltad a checkpoint tömböt, amikor értéket sehol nem adtál nekik.. Na m1 próbáld ki így.
[pawn]#include <a_samp>
#include <zcmd>
//new checkpoints[18];
//new cel;
CMD:race(playerid,params[])
{
   sPlayerPos(playerid,2045.7445,1360.8739,10.2429,0,0);
   SetPlayerCheckpoint(playerid,2047.3328,1111.7773,10.2429,8.5);
   SetPVarInt(playerid,\"CP\",1);
        return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(GetPVarInt(playerid,\"CP\") == 1)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2015.4202,847.9307,6.2977,8.5);
    SetPVarInt(playerid,\"CP\",2);
}
if(GetPVarInt(playerid,\"CP\") == 2)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1791.1125,817.5202,10.3641,8.5);
    SetPVarInt(playerid,\"CP\",3);
}
if(GetPVarInt(playerid,\"CP\") == 3)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1631.8530,216.9445,30.7127,8.5);
    SetPVarInt(playerid,\"CP\",4);
}
if(GetPVarInt(playerid,\"CP\") == 4)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1701.1248,-636.8368,40.6468,8.5);
    SetPVarInt(playerid,\"CP\",5);
}
if(GetPVarInt(playerid,\"CP\") == 5)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1576.2233,-1413.4781,28.0421,8.5);
    SetPVarInt(playerid,\"CP\",6);
}
if(GetPVarInt(playerid,\"CP\") == 6)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1693.2444,-1543.3309,23.1510,8.5);
    SetPVarInt(playerid,\"CP\",7);
}
if(GetPVarInt(playerid,\"CP\") == 7)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2113.5508,-1537.3674,2.0323,8.5);
    SetPVarInt(playerid,\"CP\",8);
}
if(GetPVarInt(playerid,\"CP\") == 8)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2720.7590,-1629.2537,12.4153,8.5);
    SetPVarInt(playerid,\"CP\",9);
}
if(GetPVarInt(playerid,\"CP\") == 9)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2890.6548,-1621.0668,10.4455,8.5);
    SetPVarInt(playerid,\"CP\",10);
}
if(GetPVarInt(playerid,\"CP\") == 10)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2894.3796,-935.4986,10.4460,8.5);
    SetPVarInt(playerid,\"CP\",11);
}
if(GetPVarInt(playerid,\"CP\") == 11)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2752.1931,-371.6379,24.4416,8.5);
    SetPVarInt(playerid,\"CP\",12);
}
if(GetPVarInt(playerid,\"CP\") == 12)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2776.1350,191.8326,19.8359,8.5);
    SetPVarInt(playerid,\"CP\",13);
}
if(GetPVarInt(playerid,\"CP\") == 13)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1704.2252,397.0681,29.9643,8.5);
    SetPVarInt(playerid,\"CP\",14);
}
if(GetPVarInt(playerid,\"CP\") == 14)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1825.7363,837.4744,9.9731,8.5);
    SetPVarInt(playerid,\"CP\",15);
}
if(GetPVarInt(playerid,\"CP\") == 15)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2070.1272,867.7535,6.4078,8.5);
    SetPVarInt(playerid,\"CP\",16);
}
if(GetPVarInt(playerid,\"CP\") == 16)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2086.0061,1373.9753,10.2429,8.5);
    SetPVarInt(playerid,\"CP\",17);
}
if(GetPVarInt(playerid,\"CP\") == 17)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2159.8550,1428.2513,10.3912,8.5);
    SetPVarInt(playerid,\"CP\",18);
}
if(GetPVarInt(playerid,\"CP\") == 18)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2247.2556,1465.3269,10.2428,8.5);
    SetPVarInt(playerid,\"CP\",19);
}
if(GetPVarInt(playerid,\"CP\") == 19)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2306.2717,1494.6664,10.3943,8.5);
    DisablePlayerCheckpoint(playerid);
    SendClientMessage(playerid,COLOR_LIGHTGREEN,\"A verseny végére értél!\");
}
return 1;
}[/pawn]

Nem elérhető Buba

  • 540
    • Profil megtekintése
1 Probléma
« Válasz #2 Dátum: 2011. Április 30. - 18:53:17 »
0 Show voters
Idézetet írta: straY\' date=1304182344\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"7847\" data-ipsquote-contentclass=\"forums_Topic
Hello. Nem tudom minek deklaráltad a checkpoint tömböt, amikor értéket sehol nem adtál nekik.. Na m1 próbáld ki így.
[pawn]#include <a_samp>
#include <zcmd>
//new checkpoints[18];
//new cel;
CMD:race(playerid,params[])
{
   sPlayerPos(playerid,2045.7445,1360.8739,10.2429,0,0);
   SetPlayerCheckpoint(playerid,2047.3328,1111.7773,10.2429,8.5);
   SetPVarInt(playerid,\"CP\",1);
        return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(GetPVarInt(playerid,\"CP\") == 1)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2015.4202,847.9307,6.2977,8.5);
    SetPVarInt(playerid,\"CP\",2);
}
if(GetPVarInt(playerid,\"CP\") == 2)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1791.1125,817.5202,10.3641,8.5);
    SetPVarInt(playerid,\"CP\",3);
}
if(GetPVarInt(playerid,\"CP\") == 3)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1631.8530,216.9445,30.7127,8.5);
    SetPVarInt(playerid,\"CP\",4);
}
if(GetPVarInt(playerid,\"CP\") == 4)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1701.1248,-636.8368,40.6468,8.5);
    SetPVarInt(playerid,\"CP\",5);
}
if(GetPVarInt(playerid,\"CP\") == 5)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1576.2233,-1413.4781,28.0421,8.5);
    SetPVarInt(playerid,\"CP\",6);
}
if(GetPVarInt(playerid,\"CP\") == 6)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1693.2444,-1543.3309,23.1510,8.5);
    SetPVarInt(playerid,\"CP\",7);
}
if(GetPVarInt(playerid,\"CP\") == 7)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2113.5508,-1537.3674,2.0323,8.5);
    SetPVarInt(playerid,\"CP\",8);
}
if(GetPVarInt(playerid,\"CP\") == 8)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2720.7590,-1629.2537,12.4153,8.5);
    SetPVarInt(playerid,\"CP\",9);
}
if(GetPVarInt(playerid,\"CP\") == 9)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2890.6548,-1621.0668,10.4455,8.5);
    SetPVarInt(playerid,\"CP\",10);
}
if(GetPVarInt(playerid,\"CP\") == 10)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2894.3796,-935.4986,10.4460,8.5);
    SetPVarInt(playerid,\"CP\",11);
}
if(GetPVarInt(playerid,\"CP\") == 11)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2752.1931,-371.6379,24.4416,8.5);
    SetPVarInt(playerid,\"CP\",12);
}
if(GetPVarInt(playerid,\"CP\") == 12)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2776.1350,191.8326,19.8359,8.5);
    SetPVarInt(playerid,\"CP\",13);
}
if(GetPVarInt(playerid,\"CP\") == 13)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1704.2252,397.0681,29.9643,8.5);
    SetPVarInt(playerid,\"CP\",14);
}
if(GetPVarInt(playerid,\"CP\") == 14)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,1825.7363,837.4744,9.9731,8.5);
    SetPVarInt(playerid,\"CP\",15);
}
if(GetPVarInt(playerid,\"CP\") == 15)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2070.1272,867.7535,6.4078,8.5);
    SetPVarInt(playerid,\"CP\",16);
}
if(GetPVarInt(playerid,\"CP\") == 16)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2086.0061,1373.9753,10.2429,8.5);
    SetPVarInt(playerid,\"CP\",17);
}
if(GetPVarInt(playerid,\"CP\") == 17)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2159.8550,1428.2513,10.3912,8.5);
    SetPVarInt(playerid,\"CP\",18);
}
if(GetPVarInt(playerid,\"CP\") == 18)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2247.2556,1465.3269,10.2428,8.5);
    SetPVarInt(playerid,\"CP\",19);
}
if(GetPVarInt(playerid,\"CP\") == 19)
{
    DeletePVar(playerid,\"CP\");
    SetPlayerCheckpoint(playerid,2306.2717,1494.6664,10.3943,8.5);
    DisablePlayerCheckpoint(playerid);
    SendClientMessage(playerid,COLOR_LIGHTGREEN,\"A verseny végére értél!\");
}
return 1;
}[/pawn]
 
Oks megnézem csak kaja

Nem elérhető Stray

  • 617
    • Profil megtekintése
1 Probléma
« Válasz #3 Dátum: 2011. Április 30. - 18:54:22 »
0 Show voters
Oks. Ha jó zárj, ha nem csak szólj xD

Nem elérhető Buba

  • 540
    • Profil megtekintése
1 Probléma
« Válasz #4 Dátum: 2011. Április 30. - 19:01:12 »
0 Show voters
Nem jó, ugyanaz a hiba.

Nem elérhető Stray

  • 617
    • Profil megtekintése
1 Probléma
« Válasz #5 Dátum: 2011. Április 30. - 19:07:07 »
0 Show voters
Próbáld meg úgy, hogy kiveszed a DeletePVar-okat. Csak az uccsóban hagyd meg.

Nem elérhető Buba

  • 540
    • Profil megtekintése
1 Probléma
« Válasz #6 Dátum: 2011. Április 30. - 19:11:01 »
0 Show voters
Úgy sem jó :(

Nem elérhető Stray

  • 617
    • Profil megtekintése
1 Probléma
« Válasz #7 Dátum: 2011. Április 30. - 19:25:39 »
0 Show voters
Ja megvan mi a gond! Majd késõbb megírom a javítást. Csak há\' most megyek.

1 Probléma
« Válasz #8 Dátum: 2011. Április 30. - 19:53:27 »
0 Show voters
Vicces le is kéne zárni a vizsgálatokat vagy else if utasításként kellene megvizsgálni a többit.
A hiba abból adódik hogy nincs lezárás egyetlen egy feltétel vizsgálat után:
[pawn]
if(GetPVarInt(playerid,\"CP\") == 1)
{
    SetPVarInt(playerid,\"CP\",2);
}
if(GetPVarInt(playerid,\"CP\") == 2)
{
    SetPVarInt(playerid,\"CP\",3);
}
[/pawn]
Az elsõ feltétel PVar \"CP\" = 1-el akkor beállításra kerül 2-es re az érték és már jön is a következõ ahol természetesen igaz hogy PVar \"CP\" = 2-vel, és beállításra kerül a 3-as érték és így tovább. És ez lezárások nélkül szépen le is fut egymás után egy pillanat alatt.
Két helyes megoldás:
[pawn]
[pawn]
if(GetPVarInt(playerid,\"CP\") == 1)
{
    SetPVarInt(playerid,\"CP\",2);
}
else if(GetPVarInt(playerid,\"CP\") == 2)
{
    SetPVarInt(playerid,\"CP\",3);
}
[/pawn]
vagy
[pawn]
[pawn]
if(GetPVarInt(playerid,\"CP\") == 1)
{
    SetPVarInt(playerid,\"CP\",2);
    return 1;         
}
if(GetPVarInt(playerid,\"CP\") == 2)
{
    SetPVarInt(playerid,\"CP\",3);
    return 1;
}
[/pawn]
Természetesen ennél van sokkal ésszerûbb megoldás csak a hiba miatt írtam ezeket a példákat.
« Utoljára szerkesztve: 2011. Április 30. - 19:57:03 írta Zsolesszka »

Nem elérhető Buba

  • 540
    • Profil megtekintése
1 Probléma
« Válasz #9 Dátum: 2011. Május 01. - 07:51:59 »
0 Show voters
Ezt a kis hibát hogy nem vettem észre...
kösz Zsolesszka
 Zárom a témát

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal