SA-MP Forums Archive
What's wrong here? (cmd:/buyvehicle) - 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: What's wrong here? (cmd:/buyvehicle) (/showthread.php?tid=433996)



What's wrong here? (cmd:/buyvehicle) - GBLTeam - 30.04.2013

I really cant find the problem in the cmd because when i import this cmd in fs its working but in gamemode not work i'm typing /buyvehicle(/kupivozilo) and its freezing me because (Togleplayercontrol its 0) and when i try to use the buttons left and right on the keyboard also enter its not moving only im freezed (stucked.)



CMD:
pawn Код:
dcmd_kupivozilo(playerid,params[])
{
    if(IsShoping[playerid] == 0)
    {
        if(GetPlayerState(playerid) != 2)
        {
            if(IsPlayerInRangeOfPoint(playerid,7.00,564.0015,-1283.4336,17.2559))
            {
                #pragma unused params
                TogglePlayerControllable(playerid, 0);
                new string124[128];
                IsShoping[playerid] = 1;
                SCM(playerid, aboja, " Koristi tipke lijevo i desno za listanje vozila!");
                SCM(playerid, aboja, " Za kupnju pritisni enter (F)");
                SCM(playerid, aboja, " Za prekid pritisni CTRL");
                SVozilaTextDraw(playerid);
                format(string124,sizeof(string124),"~w~%s~n~~n~~h~~h~~b~Cijena: %d~n~~n~~h~~h~~y~< ~g~dalje ~h~~h~~y~>",VehNames[vCars[ShopVeh1[1]][0] -400],vCars[ShopVeh1[1]][1]);
                TextDrawSetString(CarShopTextDraw[playerid],string124);
                }else{SCM(playerid, aboja, " Nisi u salonu!");}
            }else{SCM(playerid, aboja, " Nemozes kupovati iz vozila!");}
        }else{SCM(playerid, aboja, " Vec listas katalog!");}
    return 1;
}
IMAGE:



Re : What's wrong here? (cmd:/buyvehicle) - DaTa[X] - 30.04.2013

do you have YCMD include in your gamemode ?


Re: What's wrong here? (cmd:/buyvehicle) - Lordzy - 30.04.2013

Use 'TogglePlayerControllable(playerid, true);' under the command, that could help I guess.


Re: Re : What's wrong here? (cmd:/buyvehicle) - GBLTeam - 30.04.2013

Quote:
Originally Posted by DaTa[X]
Посмотреть сообщение
do you have YCMD include in your gamemode ?
No.

Quote:
Originally Posted by Lordz™
Посмотреть сообщение
Use 'TogglePlayerControllable(playerid, true);' under the command, that could help I guess.
Nope, if i set "true" player will move but the textdraws not working i mean next right to choose an vehicle not working.


Re: What's wrong here? (cmd:/buyvehicle) - Chenko - 01.05.2013

You need to use SelectTextDraw to be able to click on the textdraws, not TogglePlayerControllable

SelectTextDraw Wiki Page


Re: What's wrong here? (cmd:/buyvehicle) - GBLTeam - 01.05.2013

Quote:
Originally Posted by Chenko
Посмотреть сообщение
You need to use SelectTextDraw to be able to click on the textdraws, not TogglePlayerControllable

SelectTextDraw Wiki Page
Btw how the command work in (filerscript) there no SelectTextdraw on it.. I put an selecttextdraw i dont if this is correct but its not working this is freezing the player and its not abble to move right,left etc. Also i will show you down some more functions of the command.


pawn Код:
dcmd_kupivozilo(playerid,params[])
{
    if(IsShoping[playerid] == 0)
    {
        if(GetPlayerState(playerid) != 2)
        {
            if(IsPlayerInRangeOfPoint(playerid,7.00,564.0015,-1283.4336,17.2559))
            {
                #pragma unused params
                for(new i = 0; i < MAX_PLAYER_TEXT_DRAWS; i++) PlayerTextDrawSetSelectable(playerid, CarShopTextDraw:i, 1);
                SelectTextDraw(playerid, 0x00FF00FF); // Highlight green when hovering over
                new string124[128];
                IsShoping[playerid] = 1;
                SCM(playerid, aboja, " Koristi tipke lijevo i desno za listanje vozila!");
                SCM(playerid, aboja, " Za kupnju pritisni enter (F)");
                SCM(playerid, aboja, " Za prekid pritisni CTRL");
                SVozilaTextDraw(playerid);
                format(string124,sizeof(string124),"~w~%s~n~~n~~h~~h~~b~Cijena: %d~n~~n~~h~~h~~y~< ~g~dalje ~h~~h~~y~>",VehNames[vCars[ShopVeh1[1]][0] -400],vCars[ShopVeh1[1]][1]);
                TextDrawSetString(CarShopTextDraw[playerid],string124);
                }else{SCM(playerid, aboja, " Nisi u salonu!");}
            }else{SCM(playerid, aboja, " Nemozes kupovati iz vozila!");}
        }else{SCM(playerid, aboja, " Vec listas katalog!");}
    return 1;
}

pawn Код:
stock CVozilaTextDraw()
{
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid ++)
    {CarShopTextDraw[playerid] = TextDrawCreate(295.500000,310.000000,"~y~Ime~n~~n~~h~~h~~y~Cena:------~n~~n~~h~~h~~r~< ~y~dalje ~h~~h~~r~>");
    TextDrawAlignment(CarShopTextDraw[playerid],0);
    TextDrawBackgroundColor(CarShopTextDraw[playerid],0x000000ff);
    TextDrawFont(CarShopTextDraw[playerid],1);
    TextDrawLetterSize(CarShopTextDraw[playerid],0.499999,2.100000);
    TextDrawColor(CarShopTextDraw[playerid],0xffffffff);
    TextDrawSetOutline(CarShopTextDraw[playerid],1);
    TextDrawSetProportional(CarShopTextDraw[playerid],1);
    TextDrawSetShadow(CarShopTextDraw[playerid],1);}
}
stock HVozilaTextDraw(playerid)
{TextDrawHideForPlayer(playerid,CarShopTextDraw[playerid]);}
stock SVozilaTextDraw(playerid)
{TextDrawShowForPlayer(playerid,CarShopTextDraw[playerid]);}
stock DVozilaTextDraw()
{for(new playerid = 0; playerid < MAX_PLAYERS; playerid ++)
{TextDrawDestroy(CarShopTextDraw[playerid]);}}

stock ResetVehButton(playerid)
{
if(IsShoping[playerid] > 0)
    {
    new Keys, ud, lr;
    GetPlayerKeys(playerid, Keys, ud, lr);
    if(lr > 0) //desno
    {VehButtonSet[playerid][0] ++;
    VehShopChanger(playerid);}
    else if(lr < 0) //lijevo
    {VehButtonSet[playerid][1] ++;
    VehShopChanger(playerid);}
    else if(Keys & KEY_FIRE) //ctrl
    {VehButtonSet[playerid][2]++;
    VehShopChanger(playerid);}
    else if(Keys & KEY_SECONDARY_ATTACK) //enter
    {VehButtonSet[playerid][3]++;
    VehShopChanger(playerid);}
    else
    {VehButtonSet[playerid][0] = 0;
     VehButtonSet[playerid][1] = 0;
     VehButtonSet[playerid][2] = 0;
     VehButtonSet[playerid][3] = 0;
     VehShopChanger(playerid);}
     }
return 0;
}

stock VehShopChanger(playerid)
{
if(IsPlayerConnected(playerid))
    {
    if(IsShoping[playerid] == 1)
        {
        new string[128],pa = 0;
        new ime[24];
        GetPlayerName(playerid, ime, sizeof(ime));
            if(VehButtonSet[playerid][0] == 1) // desno
                    {ShopVeh1[1]++;
                    if(ShopVeh1[1] > 28) {ShopVeh1[1] = 0;}pa = 1;}
                else if(VehButtonSet[playerid][1] == 1) //lijevo
                    {ShopVeh1[1]--;
                    if (ShopVeh1[1] < 0) {ShopVeh1[1] = 28;}pa = 1;}
                else if(VehButtonSet[playerid][3] == 1) //enter
                {
                if(AllMyCars(playerid) < MAX_BUYED_VEHS)
                    {
                    if(GetPlayerMoney(playerid) >= vCars[ShopVeh1[1]][1])
                        {

                            MakeXDCarFnc(playerid,0,vCars[ShopVeh1[1]][0],543.8163,-1254.6198,16.4204,305.2091,ShopVeh1[2],ShopVeh1[3],ime);
                            TogglePlayerControllable(playerid, 1);
                            IsShoping[playerid] = 0;
                            HVozilaTextDraw(playerid);
                            SetCameraBehindPlayer(playerid);
                        }else{format(string,sizeof(string),"Nemate dovoljno novca!Ovaj auto kosta %d$",vCars[ShopVeh1[1]][1]);
                          SCM(playerid,aboja,string);}
                    }else{SCM(playerid,aboja,"Vec imas sve aute!");}
                }
                else if (VehButtonSet[playerid][2] == 1)
                {TogglePlayerControllable(playerid, 1);
                SCM(playerid, aboja, "Odustao si od kupnje novog auta!");
                IsShoping[playerid] = 0;
                HVozilaTextDraw(playerid);
                SetCameraBehindPlayer(playerid);
                }
                if(pa > 0){
                DestroyVehicle(ShopVeh1[0]);
                ShopVeh1[0] = CreateVehicle(vCars[ShopVeh1[1]][0], 553.70001221,-1282.80004883,17.10000038,270.00000000, ShopVeh1[2],ShopVeh1[3], 30000);
                format(string,sizeof(string),"~r~%s~n~~n~~h~~h~~y~Cijena: %d~n~~n~~h~~h~~r~< ~y~dalje ~h~~h~~r~>",VehNames[GetVehicleModel(ShopVeh1[0]) - 400],vCars[ShopVeh1[1]][1]);
                TextDrawSetString(CarShopTextDraw[playerid],string);pa = 0;}
            }
        else if(IsShoping[playerid] == 2)
        {
        new string[128],pa = 0;
        new ime[24];
        GetPlayerName(playerid, ime, sizeof(ime));
            if(VehButtonSet[playerid][0] == 1) // desno
                    {ShopVeh2[1]++;
                    if(ShopVeh2[1] > 9) {ShopVeh2[1] = 0;}pa = 1;}
                else if(VehButtonSet[playerid][1] == 1) //lijevo
                    {ShopVeh2[1]--;
                    if (ShopVeh2[1] < 0) {ShopVeh2[1] = 28;}pa = 1;}
                else if(VehButtonSet[playerid][3] == 1) //enter
                {
                if(AllMyBikes(playerid) < MAX_BUYED_VEHS)
                    {
                    if(GetPlayerMoney(playerid) >= vBikes[ShopVeh2[1]][1])
                        {

                            MakeXDCarFnc(playerid,1,vBikes[ShopVeh2[1]][0],1314.9003,-1859.0258,13.3255,270.3405,ShopVeh2[2],ShopVeh2[3],ime);
                            TogglePlayerControllable(playerid, 1);
                            IsShoping[playerid] = 0;
                            HVozilaTextDraw(playerid);
                            SetCameraBehindPlayer(playerid);
                        }else{format(string,sizeof(string),"Nemate dovoljno novca!Ovaj motor kosta %d$",vBikes[ShopVeh1[1]][1]);
                          SCM(playerid,aboja,string);}
                    }else{SCM(playerid,aboja,"Vec imas sve motore");}
                }
                else if (VehButtonSet[playerid][2] == 1)
                {TogglePlayerControllable(playerid, 1);
                SCM(playerid, aboja, "Odustao si od kupnje novog motora!");
                IsShoping[playerid] = 0;
                HVozilaTextDraw(playerid);
                SetCameraBehindPlayer(playerid);
                }
                if(pa > 0){
                DestroyVehicle(ShopVeh2[0]);
                ShopVeh2[0] = CreateVehicle(vBikes[ShopVeh2[1]][0], 1298.7928,-1870.8855,13.5469,349.0682, ShopVeh2[2],ShopVeh2[3], 30000);
                format(string,sizeof(string),"~w~%s~n~~n~~h~~h~~b~Cijena: %d~n~~n~~h~~h~~y~< ~g~dalje ~h~~h~~y~>",VehNames[GetVehicleModel(ShopVeh2[0]) - 400],vBikes[ShopVeh2[1]][1]);
                TextDrawSetString(CarShopTextDraw[playerid],string);pa = 0;}
            }

            /*

            In here put for Boats and AirPlanes!!!!
            */


        }
    return 1;
}