Jump to content
  • 0

probleme despre functia IsPlayerinVehicle


Sfinx_17

Question

am incercat sa imi fac un anumit cod ptr hunter...cand intrii in el sa iti ia cate un dolar pe secunda dar cand am dat compile imi arata ca e bun codul nu imi dadea nici o erroare nimic..cand intrasem in joc sa iau hunterul dc nu imi scade nimic  :-[ plz careva cn stie bine sa imi zica multumesc !

astai codul:

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(IsPlayerInVehicle(playerid, 425))
{
 	GetPlayerMoney(playerid);
 	SetTimer("FunctiaMeaPentruTimp", 1000, true);
    SendClientMessage(playerid,0xFFFFFFAA,"You're in Hunter!");
    return 1;
}
	return 0;
}

public FunctiaMeaPentruTimp() // functia asta e pentru SetTimer ce am creato deasupra
{
	print("o secunda rocmai a trecut");
}

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

IsPlayerInVehicle e pentru ID,nu pentru model,deci ca sa il folosesti IsPlayerInVehicle(playerid,2)//2 fiind o masina simpla,cu ID 2

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid)==425)
{
 	GetPlayerMoney(playerid);
 	SetTimer("FunctiaMeaPentruTimp", 1000, true);
    SendClientMessage(playerid,0xFFFFFFAA,"You're in Hunter!");
    return 1;
}
	return 0;
}

public FunctiaMeaPentruTimp() // functia asta e pentru SetTimer ce am creato deasupra
{
	print("o secunda tocmai a trecut");
}

Link to comment
Share on other sites

astai codul:

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid)==425)
{
 	GetPlayerMoney(playerid);
 	SetTimer("FunctiaMeaPentruTimp", 1000, true);
    SendClientMessage(playerid,0xFFFFFFAA,"You're in Hunter!");
    return 1;
}
	return 0;
}

public FunctiaMeaPentruTimp() // functia asta e pentru SetTimer ce am creato deasupra
{
	print("o secunda tocmai a trecut");
}

plz

Link to comment
Share on other sites

Sa dai bani faci GivePlayerMoney(playerid, +suma); sau GivePlayerMoney(playerid, -suma);

@matrixismyname: vezi cum vorbesti.

public OnPlayerStateChange(playerid, newstate, oldstate)//am scris-o din minte s-ar putea sa fie oldstate si dupa newstate
{
    if(newstate == PLAYER_STATE_DRIVER )
    {
        new veh = GetPlayerVehicleID(playerid);
        if( GetVehicleModel(veh) == 425 )
        {
            SetTimerEx("FunctiaMeaPentruTimp", 1000, 0, "i", playerid );
            SendClientMessage(playerid,0xFFFFFFAA,"You're in Hunter!");
        }
    }
    return 1;
}

forward FunctiaMeaPentruTimp(playerid);
public FunctiaMeaPentruTimp(playerid) // functia asta e pentru SetTimerEx ce am creat-o deasupra
{
    if( IsPlayerInAnyVehicle(playerid) )
    {
        if( GetVehicleModel(GetPlayerVehicleID(playerid)) == 425 )
        {
            print("o secunda tocmai a trecut");
            GivePlayerMoney(playerid, +1);
            SetTimerEx("FunctiaMeaPentruTimp", 1000, 0, "i", playerid );
        }
    }
    return 1;
}

Citeste tot:

Ceea ce ti-am facut a fost sa-ti schimb de la OnPlayerEnterVehicle la OnPlayerStateChange, care e mult mai bun decat EnterVehicle pt ca e chemat atunci cand playerul se aseaza in vehicul, nu cand deschide portiera sau apesi F si se indreapta spre vehicul.

A 2a chestie, a fost ca am setat SetTimerEx nu SetTimer, diferenta e ca Ex poate fii pus pentru un anumit parametru, ca playerid, vehicleid sau ce ai tu acolo.

A 3a chestie, nu-l am pus sa se repete deoarece in el se verifica daca playerul e inca in Hunter, si daca e Timerul se seteaza din nou, si ii da 1$ de fiecare data.

A 4a chestie, NU CONFUNDA MODELUL cu IDul ! IDul e numarul de ordine al vehiculului sau o variabila pe care i-o pui tu cu X = CreateVehicle (de exemplu ), iar modelul e felul in care arata, de exemplu la tine 425 e modelul, IDul nu e nevoie sa-l stii personal, pentru ca-l afli de la player (ca sta in el).

-Toate tutorialele postate intra aici sau puneti-le direct [url=http://www.sa-mp.ro/forum/index

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Similar Content

    • By salexm93
      Salut ,pot adauga cod la apelarea functiilor native ? De ex la CreatePickup am nevoie sa salvez date pe care sa le accesez la OnPlayerPickUpPickup(playerid, pickupid)
    • By salexm93
      Salutare 
      Poate nu inteleg eu bine , pe wiki scrie max 2048 globale si 256 per player .
      Sa luam cazul ipotetic al unui server cu 1000 de playeri online .
      new Text:xpbar[MAX_PLAYERS]; new Text:playername[MAX_PLAYERS]; Aici vor fi 2000 create ? Adica destul de aproape de limita
       
      new PlayerText:xpbar[MAX_PLAYERS]; new PlayerText:playername[MAX_PLAYERS]; Iar Aici vor fi doar 2 ?
      Totodata , PlayerTextDrawDestroy ,la onplayerdisconnect ?
    • By St3f4n36
      Cum as putea fac urmatoarea chestie:
      Daca intr-un dialog imi apare ca primeste x bani daca apasa cazul 1 ( banii formati cu new money = 100 + rand(100); )
      si dupa sa imi trimita un mesaj tot cu aceasi suma de bani x. Trebuie salvata intr-o variabila sau cum?
    • By FlobertRO
      Buna , am si eu o problema . Mi-se restarteaza serverulul random . In server_log am gasit asta : 
      Stie cineva ce pot face  Va rog ❤️ . Multumesc frumos
       
       
      [23:17:26] [join] rezana has joined the server (1:---------------------) [23:17:26] [debug] Run time error 4: "Array index out of bounds" [23:17:26] [debug] Accessing element at index 1 past array upper bound 0 [23:17:26] [debug] AMX backtrace: [23:17:26] [debug] #0 00200b24 in ?? (... <1 argument>) at GM.pwn:8108 [23:17:26] [debug] #1 000aef80 in public MP_OPC (playerid=1) at C:\Users\xda\Desktop\gamemode-impact\gamemode-rpg-impact\pawno\include\YSI\y_hooks/impl.inc:633 [23:17:26] [debug] #2 native CallLocalFunction () from samp03svr [23:17:26] [debug] #3 0000c77c in public SSCANF_OnPlayerConnect (playerid=1) at C:\Users\xda\Desktop\gamemode-impact\gamemode-rpg-impact\pawno\include\mSelection.inc:432 [23:17:26] [debug] #4 00003210 in public Itter_OnPlayerConnect (playerid=1) at C:\Users\xda\Desktop\gamemode-impact\gamemode-rpg-impact\pawno\include\sscanf2.inc:236 [23:17:26] [debug] #5 00001684 in public OnPlayerConnect (playerid=1) at C:\Users\Florin\Dxda\gamemode-impact\gamemode-rpg-impact\pawno\include\YSI\y_iterate.inc:646
    • By CenzoR
      Salut! Am conectat gamemodeul, imi zice ca baza de date s-a conectat cu succes, daaaarrr... cand vreau sa intru pe el... spune ca parola este incorecta ca si cum ai avea baza de date neconectata, datele sunt puse in gamemode, am verificat totul, de la ce poate sa vina problema ma puteti ajuta?
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.