Jump to content
  • 0

pomoc getplayerscore


Komper_

Dotaz

Popis problému:

tákže, potrebujem spravit aby ked má hráč menšie score ako 99 tak mu to niečo napíše...

 

no nejak to nefunguje

 

Chyby/varování kompilátoru a při běhu:

--

 

Kód:

 

[code=:0]
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    	if(vehicleid == 411)
    {
    	new Float:score;
    	GetPlayerScore(playerid,score);
    	if(score < 99)
    	{
        SendClientMessage(playerid, 0xFFFFFF, "{FF0000}[ {00FF00}! {FF0000}] {00FFFF}Toto vozidlo budeš môcť používať až keď dosiahneš {FF0000}100{00FFFF} bodov.");
    	}
    }
	return 1;
}
[/code]

 

 

 

Dodatečné poznámky:

--

Link to comment
Share on other sites

Recommended Posts

  • 0
    if(score < 99

 Máš tam score 99, ale třeba něakej hráč má 0-5, tim pádem tam nemůže vstoupit jen kterej bude mít score 99. A ten kterej bude mít mín nebo víc tam může. icon_e_smile.gif

 

//Blbost, přehlédl jsem se. Myslel že tam máš =, + tam máš že ti to napíše jen zprávu, takže to hráče nevyhodí nikam.

 

Edited by DIIGNITYYYY
Link to comment
Share on other sites

  • 0

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(vehicleid == 411)
        {
            new score = GetPlayerScore(playerid);
            if(score <= 99)
            {
                SendClientMessage(playerid, 0xFFFFFF, "{FF0000}[ {00FF00}! {FF0000}] {00FFFF}Toto vozidlo budeš môcť používať až keď dosiahneš {FF0000}100{00FFFF} bodov.");
                RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 1;
} 

Tohle by mělo fungovat.

Edited by Wolficek
Link to comment
Share on other sites

  • 0

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehicleid == 411)
{
if(GetPlayerScore(playerid) < 99)
{
SendClientMessage(playerid, 0xFFFFFF, "{FF0000}[ {00FF00}! {FF0000}] {00FFFF}Toto vozidlo budeš môcť používať až keď dosiahneš {FF0000}100{00FFFF} bodov.");
}
}
return 1;
}
Link to comment
Share on other sites

  • 0

Nevím, v čem to tedy je. Já jsem si to v pohodě skompiloval, jediná chyba byla jen když nebyl definvoanej a_samp, všiml jsi si i změny publicu? Celý to nahraď.

#include <a_samp>

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(vehicleid == 411)
        {
            new score = GetPlayerScore(playerid);
            if(score <= 99)
            {
                SendClientMessage(playerid, 0xFFFFFF, "{FF0000}[ {00FF00}! {FF0000}] {00FFFF}Toto vozidlo budeš môcť používať až keď dosiahneš {FF0000}100{00FFFF} bodov.");
                RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 1;
}

Toto mi jde skompilovat v pohodě.

Link to comment
Share on other sites

  • 0

a skúšal si  si vyprintovať ?

 

public OnPlayerStateChange(playerid, newstate, oldstate)
{

    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
    print("hrac nastupuje");
        new vehicleid = GetPlayerVehicleID(playerid);
        if(vehicleid == 411)
        {
        print("id vozidla je 411");
            new score = GetPlayerScore(playerid);
            if(score <= 99)
            {
                SendClientMessage(playerid, 0xFFFFFF, "{FF0000}[ {00FF00}! {FF0000}] {00FFFF}Toto vozidlo budeš môcť používať až keď dosiahneš {FF0000}100{00FFFF} bodov.");
                RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 1;
}

a poprípade skús použiť:
/wiki/OnPlayerEnterVehicle

Edited by XpresS
Link to comment
Share on other sites

  • 0

nejde neviem.

ale tie auta robím takto 

new inf1 = CreateVehicle(411, 282.8159, 1943.5248, 17.2661, -45.0000, -1, -1, 100);
new minf1 = CreateObject(19620, -500, -500, -500, 0.0, 0.0, 96.0);
AttachObjectToVehicle(minf1, inf1, 0.0, 0.0, 0.7, 0.0, 0.0, 0.0);

lebo na nom mam potom attachnuty object

Link to comment
Share on other sites

  • 0

Aha, našel jsem problém. Byl to ten problém, že to moje zjišťuje ID auta(z /dl) takže např. I Williard může být ID 411 ale není to přesně ten infernus.

Nahraď: 

new

new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid == 411)

 

(Smaž obě a jen dej tohle k závorkám

 

if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 411)

{

 

}

Link to comment
Share on other sites

  • 0

Hoši dik za rady, keď prídem z práce tak vyskúšam a dám vedieť.

Aha, našel jsem problém. Byl to ten problém, že to moje zjišťuje ID auta(z /dl) takže např. I Williard může být ID 411 ale není to přesně ten infernus.

Nahraď: 

new

new vehicleid = GetPlayerVehicleID(playerid);

if(vehicleid == 411)

 

(Smaž obě a jen dej tohle k závorkám

 

if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 411)

{

 

}

Stále to ide tak ako včera nastúpi tam za každých okolností, a ani tu správu to nenapíše.

 

Jestli pak chces konkretni vozidlo (resp. vozidlo s tim attachnutym objektem) tak 

 

if(GetPlayerVehicleID(playerid) == inf1)

Keď tam dám inf1 tak mám error undefined symbol aj ked hore v ongamemodeinit  mám new inf1 = CreateVehicle.....

Edited by Komper_
Link to comment
Share on other sites

  • 0

new inf1;

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetPlayerVehicleID(playerid) == inf1)
{
new score = GetPlayerScore(playerid);
if(score <= 99)
{
TogglePlayerControllable(playerid,0);
TogglePlayerControllable(playerid,1);
SendClientMessage(playerid, 0xFFFFFF, "{FF0000}[ {00FF00}! {FF0000}] {00FFFF}Toto vozidlo budeš môcť používať až keď dosiahneš {FF0000}100{00FFFF} bodov.");
}
}
return 1;
}
Link to comment
Share on other sites

  • 0
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        new vModel = GetVehicleModel(GetPlayerVehicleID(playerid)); 
        if(vModel == 411)
        {
            new score = GetPlayerScore(playerid);
            if(score <= 99)
            {
                new str[280];
                format(str, sizeof(str), "{FF0000}[ {00FF00}! {FF0000}] {00FFFF}Toto vozidlo budeš môcť používať až keď dosiahneš {FF0000}100{00FFFF} bodov.");
                SendClientMessage(playerid, -1, str);
                RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 1;
}

Otestováno, tohle funguje.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...