07.12.2017, 13:05
(
Последний раз редактировалось jasperschellekens; 07.12.2017 в 13:07.
Причина: onPlayerModelSelectionEx instead of onPlayerModelSelection
)
Hello everyone,
I downloaded a weed script and edited it to my needs because i didn't accomplish creating my own one (had too many bugs).
However, this system works perfectly for me but there are 2 problems.
problem 1 isn't a big problem at not required yet, the problem is that i can not implant it into my gamemode without the script loosing his mind.
The second problem and the big problem that needs to be solved is that it disables onplayermodelselectionex.
I can do my showinv (open inventory), but the onplayermodelselectionex will not execute anymore.
What in this script could be causing this?
I downloaded a weed script and edited it to my needs because i didn't accomplish creating my own one (had too many bugs).
However, this system works perfectly for me but there are 2 problems.
problem 1 isn't a big problem at not required yet, the problem is that i can not implant it into my gamemode without the script loosing his mind.
The second problem and the big problem that needs to be solved is that it disables onplayermodelselectionex.
I can do my showinv (open inventory), but the onplayermodelselectionex will not execute anymore.
What in this script could be causing this?
PHP код:
#include <a_samp>
#include <crashdetect>
#include <zcmd>
#include <sscanf2>
#include <YSI\y_iterate>
#include <YSI\y_timers>
#include <foreach>
#include <streamer>
#define MAX_WEEDS 1000
#define MAX_LOOTS 1000
#define DIALOG_WEED 6060
#define DIALOG_SEEDS 6070
new Iterator:Weeds<MAX_WEEDS>;
new Iterator:Loots<MAX_LOOTS>;
enum weedinfo {
wProgress,
wObjectID,
Float:wLocation[3],
Float:oPosition[3],
Text3D:wLabel,
Timer,
Timer:x,
wSeed
}
new WeedInfo[MAX_WEEDS][weedinfo];
enum pweedinfo {
pSelection,
Seeds[5],
Weed[5]
}
new PlayerWeedInfo[MAX_PLAYERS][pweedinfo];
enum lootinfo {
Text3D:lLabel,
Float:lLocation[3],
wType,
wGrams,
lObjectID
}
new LootInfo[MAX_LOOTS][lootinfo];
enum seedpacks {
id,
SeedName[36],
SeedPrice,
GpS,
time
}
new SeedInformation[][seedpacks] =
{
{0, "White Widow", 50, 4, 600},
{1, "Purple Haze", 100, 3, 600},
{2, "Choco Kush", 150, 4, 600}
};
new DrugsList[MAX_PLAYERS][5];
new ListChoice[MAX_PLAYERS];
new ToID[MAX_PLAYERS];
stock PlayerName(playerid)
{
new ppName[24];
GetPlayerName(playerid, ppName, 24);
return ppName;
}
public OnFilterScriptInit()
{
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerWeedInfo[playerid][pSelection] = -1;
return 1;
}
public OnPlayerDisconnect(playerid)
{
PlayerWeedInfo[playerid][pSelection] = -1;
return 1;
}
CMD:pickpackup(playerid, params[])
{
foreach(new i : Loots)
{
if(IsPlayerInRangeOfPoint(playerid, 2, LootInfo[i][lLocation][0], LootInfo[i][lLocation][1], LootInfo[i][lLocation][2]))
{
new string[128];
PlayerWeedInfo[playerid][Weed][LootInfo[i][wType]] += LootInfo[i][wGrams];
format(string, sizeof string, "* {E1E858}You have picked up a pack containing %i grams of %s.", LootInfo[i][wGrams], SeedInformation[LootInfo[i][wType]][SeedName]);
SendClientMessage(playerid, -1, string);
LootInfo[i][wGrams] = 0;
LootInfo[i][wType] = -1;
DestroyDynamic3DTextLabel(LootInfo[i][lLabel]);
DestroyDynamicObject(LootInfo[i][lObjectID]);
Iter_Remove(Loots, i);
ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0 ,0,0,0,0,1);
break;
}
}
return 1;
}
CMD:buyseeds(playerid, params[])
{
new string[1000];
//if(!IsPlayerInRangeOfPoint(playerid, 2, 0, 0, 0)) return SendClientMessage(playerid, "{FF0000}ERROR: {FFFFFF}You must be in range of the dealer to buy seed packs.");
for(new i; i < sizeof SeedInformation; i++)
{
if(i != sizeof(SeedInformation))
format(string, sizeof string, "%s{FFFFFF}[{E1E858}ID: %i{FFFFFF}] %s\t\t{FFFFFF}%d{4BD176}$\n", string, i, SeedInformation[i][SeedName], SeedInformation[i][SeedPrice]);
else
format(string, sizeof string, "%s{FFFFFF}[{E1E858}ID: %i{FFFFFF}] %s\t\t{FFFFFF}%d{4BD176}$", string, SeedInformation[i][SeedName], SeedInformation[i][SeedPrice]);
}
PlayerWeedInfo[playerid][pSelection] = -1;
ShowPlayerDialog(playerid, DIALOG_WEED, DIALOG_STYLE_LIST, "{EBC11A}WEED: {FFFFFF}Seeds menu", string, "Buy", "Close");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_WEED) //1
{
if(response)
{
PlayerWeedInfo[playerid][pSelection] = listitem;
ShowPlayerDialog(playerid, DIALOG_WEED+1, DIALOG_STYLE_INPUT, "{EBC11A}WEED: {FFFFFF}Seeds menu", "{FFFFFF}Select the amount of seeds you would like to buy.", "Buy", "Close");//2
}
return 1;
}
if(dialogid == DIALOG_WEED+1) //2
{
if(response)
{
if(strval(inputtext) <= 0) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}You cannot buy this amount of seeds.");
new input = strval(inputtext), selection=PlayerWeedInfo[playerid][pSelection];
//if(GetPlayerMoney(playerid) < (SeedInformation[selection][SeedPrice])*input) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You do not have enough money for these seeds.");
GivePlayerMoney(playerid, -(SeedInformation[selection][SeedPrice])*input);
PlayerWeedInfo[playerid][Seeds][selection] += input;
new string[128];
format(string, sizeof string, "* {E1E858}You have bought %i %s seeds.", input, SeedInformation[selection][SeedName]);
SendClientMessage(playerid, -1, string);
}
return 1;
}
if(dialogid == DIALOG_WEED+2) //3
{
if(response)
{
ListChoice[playerid] = listitem;
ToID[playerid] = -1;
ShowPlayerDialog(playerid, DIALOG_WEED+3, DIALOG_STYLE_LIST, "{EBC11A}WEED: {FFFFFF}Weed management", "{FFFFFF}Pack and drop\n{FFFFFF}Give to another\n{FFFFFF}Disperse", "Perform", "Close"); //4
}
return 1;
}
if(dialogid == DIALOG_WEED+3) //4
{
if(response)
{
if(listitem == 0) {
ShowPlayerDialog(playerid, DIALOG_WEED+4, DIALOG_STYLE_INPUT, "{EBC11A}WEED: {FFFFFF}Weed management", "{FFFFFF}Choose the amount of drugs you would like to package and drop:", "Pack and drop", "Close"); //7
}
if(listitem == 1) {
ShowPlayerDialog(playerid, DIALOG_WEED+5, DIALOG_STYLE_INPUT, "{EBC11A}WEED: {FFFFFF}Weed management", "{FFFFFF}Choose the person (ID) you would like to give drugs to:", "Give", "Close"); //8
if(IsPlayerConnected(strval(inputtext))) {
SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}Player ID is invalid.");
}
else {
ToID[playerid] = strval(inputtext);
}
}
if(listitem == 2) {
ShowPlayerDialog(playerid, DIALOG_WEED+6, DIALOG_STYLE_INPUT, "{EBC11A}WEED: {FFFFFF}Weed management", "{FFFFFF}Choose the amount of drugs you would like to disperse:", "Disperse", "Close"); //9
}
}
return 1;
}
if(dialogid == DIALOG_WEED+4) //7
{
if(response)
{
if(strval(inputtext) > PlayerWeedInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]] || strval(inputtext) <= 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You do not have that amount of drugs.");
new lootID = Iter_Free(Loots), Float:PPos[3];
new slot = DrugsList[playerid][ListChoice[playerid]];
GetPlayerPos(playerid, PPos[0], PPos[1], PPos[2]);
PlayerWeedInfo[playerid][Weed][slot] -= strval(inputtext);
LootInfo[lootID][lLocation][0] = PPos[0];
LootInfo[lootID][lLocation][1] = PPos[1]-0.1060;
LootInfo[lootID][lLocation][2] = PPos[2]-0.8;
LootInfo[lootID][lObjectID] = CreateDynamicObject(1575, PPos[0], PPos[1]-0.1060, PPos[2]-1, 0, 0, 0);
new title[50];
format(title, sizeof title, "{E1E858}[%i grams of %s] Press 'C' to pickup", strval(inputtext), SeedInformation[slot][SeedName]);
new string[128];
format(string, sizeof string, "* {E1E858}You have packed and dropped %i grams of %s; %i left.", strval(inputtext), SeedInformation[slot][SeedName], PlayerWeedInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]]);
SendClientMessage(playerid, -1, string);
LootInfo[lootID][lLabel] = CreateDynamic3DTextLabel(title, -1, PPos[0], PPos[1]-0.1060, PPos[2]-0.8, 5);
LootInfo[lootID][wGrams] = strval(inputtext);
LootInfo[lootID][wType] = slot;
Iter_Add(Loots, lootID);
}
return 1;
}
if(dialogid == DIALOG_WEED+5)
{
if(response)
{
ShowPlayerDialog(playerid, DIALOG_WEED+7, DIALOG_STYLE_INPUT, "{EBC11A}WEED: {FFFFFF}Weed management", "{FFFFFF}Choose the amount of drugs you would like to give this person:", "Give", "Close"); //6
}
return 1;
}
if(dialogid == DIALOG_WEED+6) //9
{
if(response)
{
if(strval(inputtext) > PlayerWeedInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]] || strval(inputtext) <= 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You do not have that amount of drugs.");
PlayerWeedInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]] -= strval(inputtext);
new string[128];
format(string, sizeof string, "* {E1E858}You have dispersed %i grams of %s; %i left.", strval(inputtext), SeedInformation[DrugsList[playerid][ListChoice[playerid]]][SeedName], PlayerWeedInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]]);
SendClientMessage(playerid, -1, string);
}
return 1;
}
if(dialogid == DIALOG_WEED+7) //6
{
if(response)
{
if(strval(inputtext) > PlayerWeedInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]] || strval(inputtext) <= 0) return SendClientMessage(playerid, -1, "{FF0000}ERROR: {FFFFFF}You do not have that amount of drugs.");
PlayerWeedInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]] -= strval(inputtext);
PlayerWeedInfo[ToID[playerid]][Weed][DrugsList[playerid][ListChoice[playerid]]] += strval(inputtext);
new string[128];
format(string, sizeof string, "* {E1E858}You have given %i grams of %s to %s; %i grams left.", strval(inputtext), SeedInformation[DrugsList[playerid][ListChoice[playerid]]][SeedName], PlayerName(ToID[playerid]), PlayerWeedInfo[playerid][Weed][DrugsList[playerid][ListChoice[playerid]]]);
SendClientMessage(playerid, -1, string);
format(string, sizeof string, "* {E1E858}You have been given %i grams of %s from %s; you now got %i grams.", strval(inputtext), SeedInformation[DrugsList[playerid][ListChoice[playerid]]][SeedName], PlayerName(playerid), PlayerWeedInfo[ToID[playerid]][Weed][DrugsList[playerid][ListChoice[playerid]]]);
SendClientMessage(playerid, -1, string);
}
return 1;
}
return 0;
}
CMD:mydrugs(playerid, params[])
{
new string[1000], templates[128], results = 0;
for(new i; i < 5; i++)
{
if(PlayerWeedInfo[playerid][Weed][i] != 0) {
format(templates, sizeof templates, "{FFFFFF}[{E1E858}Slot: %i{FFFFFF}] %i grams of %s{FFFFFF}.\n", i, PlayerWeedInfo[playerid][Weed][i], SeedInformation[i][SeedName]);
strcat(string, templates, sizeof string);
DrugsList[playerid][results] = i;
results++;
}
}
if(results == 0) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}You do not have any drugs.");
ShowPlayerDialog(playerid, DIALOG_WEED+2, DIALOG_STYLE_LIST, "{EBC11A}WEED: {FFFFFF}My drugs", string, "Manage", "Close");
return 1;
}
CMD:plantseed(playerid, params[])
{
new slot;
if(sscanf(params, "i", slot)) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}/plantseeds [slot (/myseeds for slot]");
foreach(new i : Weeds)
{
if(IsPlayerInRangeOfPoint(playerid, 5, WeedInfo[i][wLocation][0], WeedInfo[i][wLocation][1], WeedInfo[i][wLocation][2]))
{
return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}You cannot plant a weed plant so close to another.");
}
}
if(PlayerWeedInfo[playerid][Seeds][slot] != 0)
{
new weedID = Iter_Free(Weeds), Float:PPos[3];
GetPlayerPos(playerid, PPos[0], PPos[1], PPos[2]);
WeedInfo[weedID][wSeed] = slot;
WeedInfo[weedID][wProgress] = 0;
WeedInfo[weedID][wLocation][0] = PPos[0];
WeedInfo[weedID][wLocation][1] = PPos[1];
WeedInfo[weedID][wLocation][2] = PPos[2];
WeedInfo[weedID][wObjectID] = CreateDynamicObject(19473, PPos[0], PPos[1], PPos[2]-2.2100, 0, 0, 0);
WeedInfo[weedID][oPosition][0] = PPos[0];
WeedInfo[weedID][oPosition][1] = PPos[1];
WeedInfo[weedID][oPosition][2] = PPos[2]-2.2100;
new title[50];
format(title, sizeof title, "{E1E858}[%s - 0%%]", SeedInformation[slot][SeedName]);
WeedInfo[weedID][wLabel] = CreateDynamic3DTextLabel(title, -1, PPos[0], PPos[1], PPos[2], 15.0);
WeedInfo[weedID][x] = repeat WeedProg(weedID, slot);
PlayerWeedInfo[playerid][Seeds][slot] -= 1;
Iter_Add(Weeds, weedID);
ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0 ,0,0,0,0,1);
}
else SendClientMessage(playerid, -1, "* {FF0000}Error: {FFFFFF}You do not have any seeds in that slot.");
return 1;
}
timer WeedProg[1000](weedID, slot)
{
new title[50];
new Float:fPercentage = (float(WeedInfo[weedID][wProgress])/float(SeedInformation[slot][time])) * 100.0;
new percentage = floatround(fPercentage, floatround_floor);
if(WeedInfo[weedID][Timer] == SeedInformation[slot][time]) stop WeedInfo[weedID][x];
new Float:valIncr = (percentage*1.105)/100;
printf("Weed ID: %i; Progress %i; valIncr %f",weedID, WeedInfo[weedID][wProgress], valIncr);
if(WeedInfo[weedID][wProgress] < SeedInformation[slot][time])
{
WeedInfo[weedID][wProgress]++;
format(title, sizeof title, "{E1E858}[%s - %i%%]", SeedInformation[slot][SeedName], percentage);
SetDynamicObjectPos(WeedInfo[weedID][wObjectID], WeedInfo[weedID][oPosition][0], WeedInfo[weedID][oPosition][1], WeedInfo[weedID][oPosition][2]+valIncr);
UpdateDynamic3DTextLabelText(WeedInfo[weedID][wLabel], -1, title);
}
else
{
WeedInfo[weedID][wProgress] = SeedInformation[slot][time];
SetDynamicObjectPos(WeedInfo[weedID][wObjectID], WeedInfo[weedID][oPosition][0], WeedInfo[weedID][oPosition][1], WeedInfo[weedID][oPosition][2]+1.105);
format(title, sizeof title, "{E1E858}[%s - completed - Press key 'H' to harvest]", SeedInformation[slot][SeedName]);
UpdateDynamic3DTextLabelText(WeedInfo[weedID][wLabel], -1, title);
}
WeedInfo[weedID][Timer]++;
return 1;
}
CMD:myseeds(playerid, params[])
{
new string[1000], templates[128], results = 0;
for(new i; i < 5; i++)
{
if(PlayerWeedInfo[playerid][Seeds][i] != 0) {
format(templates, sizeof templates, "{FFFFFF}[{E1E858}Slot: %i{FFFFFF}] {FFFFFF}%i seeds of %s{FFFFFF}.\n", i, PlayerWeedInfo[playerid][Seeds][i], SeedInformation[i][SeedName]);
strcat(string, templates, sizeof string);
results++;
}
}
if(results == 0) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}You do not have any seeds.");
ShowPlayerDialog(playerid, DIALOG_SEEDS, DIALOG_STYLE_MSGBOX, "{EBC11A}WEED: {FFFFFF}My seeds", string, "Okay", "");
return 1;
}
CMD:collectweed(playerid, params[])
{
new result = 0, prog=0, slot;
foreach(new i : Weeds)
{
if(IsPlayerInRangeOfPoint(playerid, 2, WeedInfo[i][wLocation][0], WeedInfo[i][wLocation][1], WeedInfo[i][wLocation][2]))
{
result = 1;
slot = WeedInfo[i][wSeed];
if(WeedInfo[i][wProgress] == SeedInformation[slot][time])
{
PlayerWeedInfo[playerid][Weed][slot] += SeedInformation[slot][GpS];
new string[128];
format(string, sizeof string, "* {E1E858}You have collected %s plant and earned %i grams.", SeedInformation[slot][SeedName], SeedInformation[slot][GpS]);
SendClientMessage(playerid, -1, string);
WeedInfo[i][wSeed] = -1;
DestroyDynamic3DTextLabel(WeedInfo[i][wLabel]);
DestroyDynamicObject(WeedInfo[i][wObjectID]);
WeedInfo[i][Timer] = 0;
ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0 ,0,0,0,0,1);
Iter_Remove(Weeds, i);
prog = 1;
break;
}
}
}
if(result == 0) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}You are not in range of any weed plant.");
if(prog == 0) return SendClientMessage(playerid, -1, "* {FF0000}ERROR: {FFFFFF}The plant is not fully grown yet and therefore cannot be collected.");
return 1;
}