Mselection onplayermodelselection not working.
#1

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?

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"504600},
    {
1"Purple Haze"1003600},
    {
2"Choco Kush"1504600}
};
new 
DrugsList[MAX_PLAYERS][5];
new 
ListChoice[MAX_PLAYERS];
new 
ToID[MAX_PLAYERS];
stock PlayerName(playerid)
{
    new 
ppName[24];
    
GetPlayerName(playeridppName24);
     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(playeridparams[])
{
    foreach(new 
Loots)
    {
        if(
IsPlayerInRangeOfPoint(playerid2LootInfo[i][lLocation][0], LootInfo[i][lLocation][1], LootInfo[i][lLocation][2]))
        {
            new 
string[128];
            
PlayerWeedInfo[playerid][Weed][LootInfo[i][wType]] += LootInfo[i][wGrams];
            
format(stringsizeof string"* {E1E858}You have picked up a pack containing %i grams of %s."LootInfo[i][wGrams], SeedInformation[LootInfo[i][wType]][SeedName]);
            
SendClientMessage(playerid, -1string);
            
LootInfo[i][wGrams] = 0;
            
LootInfo[i][wType] = -1;
            
DestroyDynamic3DTextLabel(LootInfo[i][lLabel]);
            
DestroyDynamicObject(LootInfo[i][lObjectID]);
            
Iter_Remove(Lootsi);
            
ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,,0,0,0,0,1);
            break;
        }
    }
    return 
1;
}
CMD:buyseeds(playeridparams[])
{
    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 isizeof SeedInformationi++)
    {
        if(
!= sizeof(SeedInformation))
            
format(stringsizeof string"%s{FFFFFF}[{E1E858}ID: %i{FFFFFF}] %s\t\t{FFFFFF}%d{4BD176}$\n"stringiSeedInformation[i][SeedName], SeedInformation[i][SeedPrice]);
        else
            
format(stringsizeof string"%s{FFFFFF}[{E1E858}ID: %i{FFFFFF}] %s\t\t{FFFFFF}%d{4BD176}$"stringSeedInformation[i][SeedName], SeedInformation[i][SeedPrice]);
    }
    
    
PlayerWeedInfo[playerid][pSelection] = -1;
    
ShowPlayerDialog(playeridDIALOG_WEEDDIALOG_STYLE_LIST"{EBC11A}WEED: {FFFFFF}Seeds menu"string"Buy""Close");
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == DIALOG_WEED//1
    
{
        if(
response)
        {
            
PlayerWeedInfo[playerid][pSelection] = listitem;
            
ShowPlayerDialog(playeridDIALOG_WEED+1DIALOG_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(stringsizeof string"* {E1E858}You have bought %i %s seeds."inputSeedInformation[selection][SeedName]);
            
SendClientMessage(playerid, -1string);
        }
        return 
1;
    }
    if(
dialogid == DIALOG_WEED+2//3
    
{
        if(
response)
        {
            
ListChoice[playerid] = listitem;
            
ToID[playerid] = -1;
            
ShowPlayerDialog(playeridDIALOG_WEED+3DIALOG_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(playeridDIALOG_WEED+4DIALOG_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(playeridDIALOG_WEED+5DIALOG_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(playeridDIALOG_WEED+6DIALOG_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(playeridPPos[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(1575PPos[0], PPos[1]-0.1060PPos[2]-1000);
            new 
title[50];
            
format(titlesizeof title"{E1E858}[%i grams of %s] Press 'C' to pickup"strval(inputtext), SeedInformation[slot][SeedName]);
            new 
string[128];
            
format(stringsizeof 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, -1string);
            
            
LootInfo[lootID][lLabel] = CreateDynamic3DTextLabel(title, -1PPos[0], PPos[1]-0.1060PPos[2]-0.85);
            
LootInfo[lootID][wGrams] = strval(inputtext);
            
LootInfo[lootID][wType] = slot;
            
            
Iter_Add(LootslootID);
        }
        return 
1;
    }
    
     if(
dialogid == DIALOG_WEED+5)
    {
        if(
response)
        {
            
ShowPlayerDialog(playeridDIALOG_WEED+7DIALOG_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(stringsizeof 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, -1string);
        }
        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(stringsizeof 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, -1string);
            
format(stringsizeof 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, -1string);
        }
        return 
1;
    }
    return 
0;
}
CMD:mydrugs(playeridparams[])
{
    new 
string[1000], templates[128], results 0;
    for(new 
i5i++)
    {
        if(
PlayerWeedInfo[playerid][Weed][i] != 0) {
            
format(templatessizeof templates"{FFFFFF}[{E1E858}Slot: %i{FFFFFF}] %i grams of %s{FFFFFF}.\n"iPlayerWeedInfo[playerid][Weed][i], SeedInformation[i][SeedName]);
            
strcat(stringtemplatessizeof string);
            
DrugsList[playerid][results] = i;
            
results++;
        }
    }
    if(
results == 0) return SendClientMessage(playerid, -1"* {FF0000}ERROR: {FFFFFF}You do not have any drugs.");
    
ShowPlayerDialog(playeridDIALOG_WEED+2DIALOG_STYLE_LIST"{EBC11A}WEED: {FFFFFF}My drugs"string"Manage""Close");
    return 
1;
}
CMD:plantseed(playeridparams[])
{
    new 
slot;
    if(
sscanf(params"i"slot)) return SendClientMessage(playerid, -1"* {FF0000}ERROR: {FFFFFF}/plantseeds [slot (/myseeds for slot]");
    foreach(new 
Weeds)
    {
        if(
IsPlayerInRangeOfPoint(playerid5WeedInfo[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(playeridPPos[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(19473PPos[0], PPos[1], PPos[2]-2.2100000);
        
WeedInfo[weedID][oPosition][0] = PPos[0];
        
WeedInfo[weedID][oPosition][1] = PPos[1];
        
WeedInfo[weedID][oPosition][2] = PPos[2]-2.2100;
        
        new 
title[50];
        
format(titlesizeof title"{E1E858}[%s - 0%%]"SeedInformation[slot][SeedName]);
        
WeedInfo[weedID][wLabel] = CreateDynamic3DTextLabel(title, -1PPos[0], PPos[1], PPos[2], 15.0);
        
        
        
WeedInfo[weedID][x] = repeat WeedProg(weedIDslot);
        
        
PlayerWeedInfo[playerid][Seeds][slot] -= 1;
        
        
Iter_Add(WeedsweedID);
        
ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.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](weedIDslot)
{
    new 
title[50];
    
    
    new 
Float:fPercentage = (float(WeedInfo[weedID][wProgress])/float(SeedInformation[slot][time])) * 100.0;
    new 
percentage floatround(fPercentagefloatround_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",weedIDWeedInfo[weedID][wProgress], valIncr);
    
    if(
WeedInfo[weedID][wProgress] < SeedInformation[slot][time])
    {
        
WeedInfo[weedID][wProgress]++;
        
format(titlesizeof 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], -1title);
    }
    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(titlesizeof title"{E1E858}[%s - completed - Press key 'H' to harvest]"SeedInformation[slot][SeedName]);
        
UpdateDynamic3DTextLabelText(WeedInfo[weedID][wLabel], -1title);
    }
    
WeedInfo[weedID][Timer]++;
    return 
1;
}
CMD:myseeds(playeridparams[])
{
    new 
string[1000], templates[128], results 0;
    for(new 
i5i++)
    {
        if(
PlayerWeedInfo[playerid][Seeds][i] != 0) {
            
format(templatessizeof templates"{FFFFFF}[{E1E858}Slot: %i{FFFFFF}] {FFFFFF}%i seeds of %s{FFFFFF}.\n"iPlayerWeedInfo[playerid][Seeds][i], SeedInformation[i][SeedName]);
            
strcat(stringtemplatessizeof string);
            
results++;
        }
    }
    if(
results == 0) return SendClientMessage(playerid, -1"* {FF0000}ERROR: {FFFFFF}You do not have any seeds.");
    
ShowPlayerDialog(playeridDIALOG_SEEDSDIALOG_STYLE_MSGBOX"{EBC11A}WEED: {FFFFFF}My seeds"string"Okay""");
    return 
1;
}
CMD:collectweed(playeridparams[])
{
    new 
result 0prog=0slot;
    foreach(new 
Weeds)
    {
        if(
IsPlayerInRangeOfPoint(playerid2WeedInfo[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(stringsizeof string"* {E1E858}You have collected %s plant and earned %i grams."SeedInformation[slot][SeedName], SeedInformation[slot][GpS]);
                
SendClientMessage(playerid, -1string);
                
                
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,1);
                
Iter_Remove(Weedsi);
                
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;

Reply
#2

Are you using similar dialog ID's in other filter(scripts)? Returning 1 from a DialogResponse callback in a filterscript will cause other scripts to not receive the callback.
Reply
#3

Thank you for your respond.
These dialogs have like all dialogs in my server an unique dialogid.
#define DIALOG_WEED 6060
#define DIALOG_SEEDS 6070
Also my mselection menus arent dialogs but they are created with textdraws.
Reply
#4

bump
Reply
#5

No need to bump. We need more information regarding your script.

What exactly goes wrong when you use this? Which script is "losing his mind"? How is it "losing his mind"?
Reply
#6

Try update mSelection.

https://sampforum.blast.hk/showthread.php?tid=645620
Reply
#7

Thank you for your help, I did try to update the plugin but it didn't work.
This is how it works without weed system:
https://*********/H_Ctq2dyWOg

If i add the weed system this happens:
https://*********/b4sZMHhf3HM
clicking on the item /closing the inv does not work
Reply
#8

bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)