13.04.2016, 23:43
I have a problem with command for buying a vehicle, command is /vsellto [id] [price] and it shows in dialog, but when i offer someone car when he press accept to buy a vehicle, nothing happens and the player gets frozen.
Код:
else if(strcmp(x_nr,"sellto",true) == 0) { if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey] || GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2] || GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { new stringa[512]; new stringaa[512]; new ponudakola[1024]; GetPlayerName(playerid, sendername, sizeof(sendername)); new ownvehkey; if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { ownvehkey = PlayerInfo[playerid][pPcarkey]; } else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { ownvehkey = PlayerInfo[playerid][pPcarkey2]; } else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { ownvehkey = PlayerInfo[playerid][pPcarkey3]; } else { return 1; } if(strcmp(sendername, CarInfo[ownvehkey][cOwner], true) == 0) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "Podsetnik: /v sellto [ID Igraca/Dio Imena] [price]"); return 1; } giveplayerid = ReturnUser(tmp); if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { if(ProxDetectorS(8.0, playerid, giveplayerid)) { if(PlayerInfo[giveplayerid][pPcarkey] == 999) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "Podsetnik: /v sellto [ID Igraca/Dio Imena] [price]"); return 1; } new newcar = GetPlayerVehicleID(playerid); new price = PlayerInfo[playerid][pEvro]; price = strval(tmp); if(price < 1 || price > 100000) { SendClientMessage(playerid, COLOR_GREY, " Cena ne moze biti manja od 1 ni veca od 100000. "); return 1; } GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); format(string, sizeof(string), "* Ponudili ste vas auto %s-u za %dE .", giveplayer, price); SendClientMessage(playerid, COLOR_WHITE, string); format(stringa, sizeof(stringa), "* Vlasnik auta %s vam je ponudio auto/motor za %dE.\n", playername, price); //SendClientMessage(giveplayerid, COLOR_WHITE, string); format(stringaa, sizeof(stringaa), "Model: %s | Cena vozila na /v buy je %dE",CarInfo[newcar][cDescription],CarInfo[newcar][cValue]); format(ponudakola,sizeof(ponudakola),"%s%s",stringa,stringaa); ShowPlayerDialog(giveplayerid,SELLTOCAR,DIALOG_STYLE_MSGBOX,"{2ECCFA}Vozilo",ponudakola,"Prihvati","Odbij"); //SendClientMessage(giveplayerid, COLOR_BLUE, string); OwnableCarOffer[giveplayerid] = playerid; OwnableCarID[giveplayerid] = ownvehkey; OwnableCarPrice[giveplayerid] = price; TogglePlayerControllable(giveplayerid,0); PonudioKola[playerid] = 1; return 1; } else if(PlayerInfo[giveplayerid][pPcarkey2] == 999) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "Podsetnik: /v sellto [ID Igraca/Dio Imena] [price]"); return 1; } new newcar = GetPlayerVehicleID(playerid); //new price = PlayerInfo[giveplayerid][pEvro]; new price = PlayerInfo[playerid][pEvro]; price = strval(tmp); if(price < 1 || price > 100000) { SendClientMessage(playerid, COLOR_GREY, " Cena ne moze biti manja od 1 ni veca od 1500000. "); return 1; } GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); format(string, sizeof(string), "* Ponudili ste vas auto %s-u za %dE .", giveplayer, price); SendClientMessage(playerid, COLOR_WHITE, string); format(stringa, sizeof(stringa), "* Vlasnik auta %s vam je ponudio auto/motor za %dE.\n", playername, price); //SendClientMessage(giveplayerid, COLOR_WHITE, string); format(stringaa, sizeof(stringaa), "Model: %s | Cena vozila na /v buy je %dE",CarInfo[newcar][cDescription],CarInfo[newcar][cValue]); format(ponudakola,sizeof(ponudakola),"%s%s",stringa,stringaa); ShowPlayerDialog(giveplayerid,SELLTOCAR,DIALOG_STYLE_MSGBOX,"{2ECCFA}Vozilo",ponudakola,"Prihvati","Odbij"); //SendClientMessage(giveplayerid, COLOR_BLUE, string); OwnableCarOffer[giveplayerid] = playerid; OwnableCarID[giveplayerid] = ownvehkey; OwnableCarPrice[giveplayerid] = price; TogglePlayerControllable(giveplayerid,0); PonudioKola[playerid] = 1; return 1; } else if(PlayerInfo[giveplayerid][pPcarkey3] == 999) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "Podsetnik: /v sellto [ID Igraca/Dio Imena] [price]"); return 1; } new newcar = GetPlayerVehicleID(playerid); //new price = PlayerInfo[giveplayerid][pEvro]; new price = PlayerInfo[playerid][pEvro]; price = strval(tmp); if(price < 1 || price > 100000) { SendClientMessage(playerid, COLOR_GREY, " Cena ne moze biti manja od 1 ni veca od 1500000. "); return 1; } GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer)); format(string, sizeof(string), "* Ponudili ste vas auto %s-u za %dE .", giveplayer, price); SendClientMessage(playerid, COLOR_WHITE, string); format(stringa, sizeof(stringa), "* Vlasnik auta %s vam je ponudio auto/motor za %dE.\n", playername, price); //SendClientMessage(giveplayerid, COLOR_WHITE, string); format(stringaa, sizeof(stringaa), "Model: %s | Cena vozila na /v buy je %dE",CarInfo[newcar][cDescription],CarInfo[newcar][cValue]); format(ponudakola,sizeof(ponudakola),"%s%s",stringa,stringaa); ShowPlayerDialog(giveplayerid,SELLTOCAR,DIALOG_STYLE_MSGBOX,"{2ECCFA}Vozilo",ponudakola,"Prihvati","Odbij"); //SendClientMessage(giveplayerid, COLOR_BLUE, string); OwnableCarOffer[giveplayerid] = playerid; OwnableCarID[giveplayerid] = ownvehkey; OwnableCarPrice[giveplayerid] = price; TogglePlayerControllable(giveplayerid,0); PonudioKola[playerid] = 1; return 1; } else { SendClientMessage(playerid, COLOR_GREY, " Igrac vec ima 3 vozila ! "); return 1; } } else { SendClientMessage(playerid, COLOR_GREY, " Igrac nije blizu vas ! "); return 1; } } } } else { SendClientMessage(playerid, COLOR_GREY, " To nije vas auto"); return 1; } } else { SendClientMessage(playerid, COLOR_GREY, " Morate sjesti u autu da biste ga prodali"); return 1; } }
Код:
if(dialogid == SELLTOCAR) { if(response) { if(PonudioKola[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, " Niko vam nije ponudio auto !"); { if(PlayerInfo[playerid][pLevel] < 5) { SendClientMessage(playerid, COLOR_GREY, "[GRESKA] Morate biti barem lvl 5 da kupite vozilo!"); return 1; } if(OwnableCarOffer[playerid] < 999) { if(OwnableCarID[playerid] == 0) { return 1; } if(OwnableCarPrice[playerid] == 0 || OwnableCarPrice[playerid] > 100000) { return 1; } if(OwnableCarID[playerid] == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey]) { } else if(OwnableCarID[playerid] == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2]) { } else if(OwnableCarID[playerid] == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3]) { } else { SendClientMessage(playerid, COLOR_GREY, " Offer is no longer available"); return 1; } if(PlayerInfo[playerid][pEvro] >= OwnableCarPrice[playerid]) { } else { SendClientMessage(playerid, COLOR_GREY, "(GRESKA) Nemas dovoljno eura!"); return 1; } if(IsPlayerConnected(OwnableCarOffer[playerid])) { } else { SendClientMessage(playerid, COLOR_GREY, " Prodavac auta je offline !"); return 1; } new giveplayer[MAX_PLAYER_NAME]; GetPlayerName(OwnableCarOffer[playerid], giveplayer, sizeof(giveplayer)); GetPlayerName(playerid, sendername, sizeof(sendername)); if(PlayerInfo[playerid][pPcarkey] == 999) { if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey]) { PlayerInfo[playerid][pPcarkey] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey]; PlayerInfo[OwnableCarOffer[playerid]][pPcarkey] = 999; } else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2]) { PlayerInfo[playerid][pPcarkey] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2]; PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2] = 999; } else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3]) { PlayerInfo[playerid][pPcarkey] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3]; PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3] = 999; } else { SendClientMessage(playerid, COLOR_GREY, " Prodavac auta mora biti u svom autu !"); return 1; } format(string, sizeof(string), "* Kupili ste auto za %dE od %s-a.",OwnableCarPrice[playerid],giveplayer); SendClientMessage(playerid, COLOR_WHITE, string); format(string, sizeof(string), "* %s je kupio auto za %dE.",sendername,OwnableCarPrice[playerid]); SendClientMessage(OwnableCarOffer[playerid], COLOR_WHITE, string); RemovePlayerFromVehicle(OwnableCarOffer[playerid]); PlayerInfo[playerid][pEvro] -= OwnableCarPrice[playerid]; PlayerInfo[OwnableCarOffer[playerid]][pEvro] += OwnableCarPrice[playerid]; TogglePlayerControllable(playerid,1); strmid(CarInfo[OwnableCarID[playerid]][cOwner], sendername, 0, strlen(sendername), 999); } else if(PlayerInfo[playerid][pPcarkey2] == 999) { if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey]) { PlayerInfo[playerid][pPcarkey2] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey]; PlayerInfo[OwnableCarOffer[playerid]][pPcarkey] = 999; } else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2]) { PlayerInfo[playerid][pPcarkey2] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2]; PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2] = 999; } else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3]) { PlayerInfo[playerid][pPcarkey2] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3]; PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3] = 999; } else { SendClientMessage(playerid, COLOR_GREY, " Prodavac auta mora sjedati u svom autu !"); return 1; } format(string, sizeof(string), "* Kupili ste auto za %dE od %s-a.",OwnableCarPrice[playerid],giveplayer); SendClientMessage(playerid, COLOR_WHITE, string); format(string, sizeof(string), "* %s je kupio auto za %dE.",sendername,OwnableCarPrice[playerid]); SendClientMessage(OwnableCarOffer[playerid], COLOR_WHITE, string); RemovePlayerFromVehicle(OwnableCarOffer[playerid]); PlayerInfo[playerid][pEvro] -= OwnableCarPrice[playerid]; PlayerInfo[OwnableCarOffer[playerid]][pEvro] += OwnableCarPrice[playerid]; TogglePlayerControllable(playerid,1); strmid(CarInfo[OwnableCarID[playerid]][cOwner], sendername, 0, strlen(sendername), 999); } else if(PlayerInfo[playerid][pPcarkey3] == 999) { if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey]) { PlayerInfo[playerid][pPcarkey3] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey]; PlayerInfo[OwnableCarOffer[playerid]][pPcarkey] = 999; } else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2]) { PlayerInfo[playerid][pPcarkey3] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2]; PlayerInfo[OwnableCarOffer[playerid]][pPcarkey2] = 999; } else if(GetPlayerVehicleID(OwnableCarOffer[playerid]) == PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3]) { PlayerInfo[playerid][pPcarkey3] = PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3]; PlayerInfo[OwnableCarOffer[playerid]][pPcarkey3] = 999; } else { SendClientMessage(playerid, COLOR_GREY, " Prodavac auta mora sjedati u svom autu !"); return 1; } format(string, sizeof(string), "* Kupili ste auto za %dE od %s-a.",OwnableCarPrice[playerid],giveplayer); SendClientMessage(playerid, COLOR_WHITE, string); format(string, sizeof(string), "* %s je kupio auto za %dE.",sendername,OwnableCarPrice[playerid]); SendClientMessage(OwnableCarOffer[playerid], COLOR_WHITE, string); RemovePlayerFromVehicle(OwnableCarOffer[playerid]); PlayerInfo[playerid][pEvro] -= OwnableCarPrice[playerid]; PlayerInfo[OwnableCarOffer[playerid]][pEvro] += OwnableCarPrice[playerid]; TogglePlayerControllable(playerid,1); strmid(CarInfo[OwnableCarID[playerid]][cOwner], sendername, 0, strlen(sendername), 999); } else { SendClientMessage(playerid, COLOR_GREY, " Vec imate 3 auta ! "); return 1; } DateProp(playerid); DateProp(OwnableCarOffer[playerid]); OnPropUpdate(); OnPlayerUpdateCustom(playerid); OnPlayerUpdateCustom(OwnableCarOffer[playerid]); OwnableCarOffer[playerid] = 999; OwnableCarID[playerid] = 0; OwnableCarPrice[playerid] = 0; GameTextForPlayer(playerid, "~w~Cestitamo~n~Nemojte zaboraviti da ga parkirate (/v park)!", 5000, 3); SendClientMessage(playerid, COLOR_GRAD2, "Cestitamo na novoj kupovini!"); SendClientMessage(playerid, COLOR_GRAD2, "Kucajte /vehiclemanual da procitate uputstva za auto!"); return 1; } } } else { GetPlayerName(playerid, sendername, sizeof(sendername)); PonudioKola[playerid] = 0; TogglePlayerControllable(playerid,1); format(string, sizeof(string), "* %s je odbio ponudu.",sendername); SendClientMessage(OwnableCarOffer[playerid], COLOR_WHITE, string); return 1; } }