SA-MP Forums Archive
One error, grabweed. +1 rep - 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: One error, grabweed. +1 rep (/showthread.php?tid=430420)



One error, grabweed. +1 rep - Lynet - 13.04.2013

PHP код:
CMD:grabweed(playeridparams[])
{
    if(
PInfo[playerid][Drugs] < 1) return SendClientMessage(playeridCOLOR_BROWN"You are not an supplier rank 1.");
    
SendClientMessage(playeridCOLOR_GREY"You are not at the druglab.");
    if(
IsPlayerInRangeOfPoint(playerid3.0302.6837,300.7080,999.1484,4.5756))
    {
    
PInfo[playerid] +=20;
    
SendClientMessage(playeridCOLOR_RED"You cutted a 20gram of weed as you pocket it.");
    
SendClientMessage(playeridCOLOR_YELLOW"SERVER: /checkweed for check how many grams you have left.");
    return 
1;
    }
    return 
1;

the error:

PHP код:
 error 023: array assignment must be simple assignment 



Re : One error, grabweed. +1 rep - DaTa[X] - 13.04.2013

Try this
pawn Код:
CMD:grabweed(playerid, params[])
{
    if(PInfo[playerid][Drugs] < 1) return SendClientMessage(playerid, COLOR_BROWN, "You are not an supplier rank 1.");
    SendClientMessage(playerid, COLOR_GREY, "You are not at the druglab.");
    if(IsPlayerInRangeOfPoint(playerid, 3.0, 302.6837,300.7080,999.1484))
    {
    PInfo[playerid][Drugs] +=20;
    SendClientMessage(playerid, COLOR_RED, "You cutted a 20gram of weed as you pocket it.");
    SendClientMessage(playerid, COLOR_YELLOW, "SERVER: /checkweed for check how many grams you have left.");
    return 1;
    }
    return 1;
}
EDITED


Re: One error, grabweed. +1 rep - Isolated - 13.04.2013

pawn Код:
PInfo[playerid] +=20;
change to
pawn Код:
PInfo[playerid][Drugs] +=20;
Also everytime someone types your command, it'll display a message, even if they are at the druglab.


Re: One error, grabweed. +1 rep - [XST]O_x - 13.04.2013

pawn Код:
PInfo[playerid] +=20;
You are missing something here. It should be PInfo[playerid][SOMETHING] += 20;


Re: One error, grabweed. +1 rep - Lynet - 13.04.2013

Same :/


Re: One error, grabweed. +1 rep - JJB562 - 13.04.2013

Like everyone else said you must add another array to

pawn Код:
PInfo[playerid] += 20;
So it would be like:

pawn Код:
PInfo[playerid][SOMETHING] += 20;
Anyways, I edited your code so it can work better:

pawn Код:
CMD:grabweed(playerid, params[])
{
    if(PInfo[playerid][Drugs] < 1) return SendClientMessage(playerid, COLOR_BROWN, "You are not an supplier rank 1.");
    if(IsPlayerInRangeOfPoint(playerid, 3.0, 302.6837,300.7080,999.1484,4.5756))
    {
        PInfo[playerid][SOMETHING] +=20;
        SendClientMessage(playerid, COLOR_RED, "You cutted a 20gram of weed as you pocket it.");
        SendClientMessage(playerid, COLOR_YELLOW, "SERVER: /checkweed for check how many grams you have left.");
    }
    else SendClientMessage(playerid, COLOR_GREY, "You are not at the druglab.");
    return 1;
}



Re: One error, grabweed. +1 rep - XStormiest - 13.04.2013

pawn Код:
CMD:grabweed(playerid, params[])
{
    if(PInfo[playerid][Drugs] < 1) return SendClientMessage(playerid, COLOR_BROWN, "You are not an supplier rank 1.");
    if(IsPlayerInRangeOfPoint(playerid, 3.0, 302.6837,300.7080,999.1484,4.5756))
    {
        PInfo[playerid][Drugs] +=20;
        SendClientMessage(playerid, COLOR_RED, "You cutted a 20gram of weed as you pocket it.");
        SendClientMessage(playerid, COLOR_YELLOW, "SERVER: /checkweed for check how many grams you have left.");
    }
    else SendClientMessage(playerid, COLOR_GREY, "You are not at the druglab.");
    return 1;
}
this is the code