4 errors(compile) in_array doesn't work
#1

hello ,
i wanna make something is that if player goes binco and types for example the command /buyclothes (id )
it works but i want to disactive some skins id from there so that player if he types a SKIN id already on the array for example 70 , he will tell hem restricted skin .. so i've created an array but this last wont work( wont get compiled )

have alook on that code and tell me why isnt working


PHP код:
C:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24975) : error 048: array dimensions do not match
C
:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24975) : error 001expected token","but found "sizeof"
C:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24975) : warning 215expression has no effect
C
:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24975) : error 001expected token";"but found ")"
C:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24975) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

PHP код:

if you guys want the command i'll pass it 
PHP код:
if(dialogid == SKINMENU)
{
         if(
response)
        {
            new 
price BizzInfo[PlayerInfo[playerid][InBusiness]][bProductPrice1];
            new 
Coolarray[][] = {
                
"70",
                
"71",
                
"274"
            
};
             if(!(
in_array(Coolarraystrval(inputtext), size sizeof Coolarray))) { //****24975****
                
if(strval(inputtext) < || strval(inputtext) > 299) { SendClientMessage(playeridCOLOR_GREY"   Skin can't be below 0 or above 299!"); return 1; }
                if(
IsInvalidSkin(strval(inputtext))) { SendClientMessage(playeridCOLOR_GREY"   Invalid skin!"); return 1; }
                if(
PlayerInfo[playerid][pCash] >= price)
                {
                    
SetPlayerSkin(playeridstrval(inputtext));
                    
PlayerInfo[playerid][pModel] = strval(inputtext);
                    
format(stringsizeof(string), "You're new clothes have been purchased for $%d."price);
                    
SendClientMessage(playeridCOLOR_YELLOWstring);
                    
PlayerInfo[playerid][pCash] -= price;
                    
GivePlayerMoney(playerid, -price);
                    
BizzInfo[PlayerInfo[playerid][InBusiness]][bTill] += price;
                    
SaveBusiness(PlayerInfo[playerid][InBusiness]);
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GREY"You don't have enough money!");
                    return 
1;
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_GREY"Restricted skin!");
                return 
1;
               }
        }
    } 
Reply
#2

pawn Код:
if(!(in_array(Coolarray, strval(inputtext), /*size = */sizeof( Coolarray))))
EDIT: im not sure about this.:P just unquote if it still got an error
Reply
#3

PHP код:
C:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24986) : error 017undefined symbol "in_array"
C:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24986) : warning 202number of arguments does not match definition 
PHP код:
    if(dialogid == SKINMENU)
 {
         if(
response)
        {
            new 
price BizzInfo[PlayerInfo[playerid][InBusiness]][bProductPrice1];
            new 
Coolarray[][] = {
                
"70",
                
"71",
                
"274"
            
};
             if(!(
in_array(Coolarraystrval(inputtext), /*size = */sizeofCoolarray)))) { //  24986 line 
                
if(strval(inputtext) < || strval(inputtext) > 299) { SendClientMessage(playeridCOLOR_GREY"   Skin can't be below 0 or above 299!"); return 1; }
                if(
IsInvalidSkin(strval(inputtext))) { SendClientMessage(playeridCOLOR_GREY"   Invalid skin!"); return 1; }
                if(
PlayerInfo[playerid][pCash] >= price)
                {
                    
SetPlayerSkin(playeridstrval(inputtext));
                    
PlayerInfo[playerid][pModel] = strval(inputtext);
                    
format(stringsizeof(string), "You're new clothes have been purchased for $%d."price);
                    
SendClientMessage(playeridCOLOR_YELLOWstring);
                    
PlayerInfo[playerid][pCash] -= price;
                    
GivePlayerMoney(playerid, -price);
                    
BizzInfo[PlayerInfo[playerid][InBusiness]][bTill] += price;
                    
SaveBusiness(PlayerInfo[playerid][InBusiness]);
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GREY"You don't have enough money!");
                    return 
1;
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_GREY"Restricted skin!");
                return 
1;
               }
        }
    } 
Reply
#4

in_array definition?
Reply
#5

Sawalha in_array just i found the idea on c++ lang . so in samp i dont know alot about it , if you know how to define it , becuause it's not like in c++
Reply
#6

Oh, Then try
pawn Код:
if(!(in_array(Coolarray, strval(inputtext))))
without "sizeof"
Reply
#7

PHP код:
C:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24976) : error 017undefined symbol "in_array" 
PHP код:

if(dialogid == SKINMENU
 { 
         if(
response
        { 
            new 
price BizzInfo[PlayerInfo[playerid][InBusiness]][bProductPrice1]; 
            new 
Coolarray[][] = { 
                
"70"
                
"71"
                
"274" 
            
}; 
             if(!(
in_array(Coolarraystrval(inputtext)))) { //  24976 line  
                
if(strval(inputtext) < || strval(inputtext) > 299) { SendClientMessage(playeridCOLOR_GREY"   Skin can't be below 0 or above 299!"); return 1; } 
                if(
IsInvalidSkin(strval(inputtext))) { SendClientMessage(playeridCOLOR_GREY"   Invalid skin!"); return 1; } 
                if(
PlayerInfo[playerid][pCash] >= price
                { 
                    
SetPlayerSkin(playeridstrval(inputtext)); 
                    
PlayerInfo[playerid][pModel] = strval(inputtext); 
                    
format(stringsizeof(string), "You're new clothes have been purchased for $%d."price); 
                    
SendClientMessage(playeridCOLOR_YELLOWstring); 
                    
PlayerInfo[playerid][pCash] -= price
                    
GivePlayerMoney(playerid, -price); 
                    
BizzInfo[PlayerInfo[playerid][InBusiness]][bTill] += price
                    
SaveBusiness(PlayerInfo[playerid][InBusiness]); 
                } 
                else 
                { 
                    
SendClientMessage(playeridCOLOR_GREY"You don't have enough money!"); 
                    return 
1
                } 
            } 
            else 
            { 
                
SendClientMessage(playeridCOLOR_GREY"Restricted skin!"); 
                return 
1
               } 
        } 
    } 
Reply
#8

in_array function is not installed in PAWNO version, You may define it:
pawn Код:
stock in_array(array[], value, size = sizeof array)
{
    for(new i; i < size; i++)
    {
        if(array[i] == value) return 1;
    }
    return 0;
}
// By Misiur
you can now add sizeof.
Reply
#9

let me see if it will work
Reply
#10

PHP код:
C:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24976) : error 029invalid expressionassumed zero
C
:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24976) : error 001expected token","but found "sizeof"
C:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24976) : warning 215expression has no effect
C
:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24976) : error 001expected token";"but found ")"
C:\Users\ZOFTer\Desktop\0.3Z server\gamemodes\UG-RP.pwn(24976) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

PHP код:

if(dialogid == SKINMENU
    { 
         if(
response
        { 
            new 
price BizzInfo[PlayerInfo[playerid][InBusiness]][bProductPrice1]; 
            new 
Coolarray[][] = { 
                
"70"
                
"71"
                
"274" 
            
}; 
                if(!(
in_array(Coolarray[], valuesize sizeof Coolarray))) {  // 24976
                
if(strval(inputtext) < || strval(inputtext) > 299) { SendClientMessage(playeridCOLOR_GREY"   Skin can't be below 0 or above 299!"); return 1; } 
                if(
IsInvalidSkin(strval(inputtext))) { SendClientMessage(playeridCOLOR_GREY"   Invalid skin!"); return 1; } 
                if(
PlayerInfo[playerid][pCash] >= price
                { 
                    
SetPlayerSkin(playeridstrval(inputtext)); 
                    
PlayerInfo[playerid][pModel] = strval(inputtext); 
                    
format(stringsizeof(string), "You're new clothes have been purchased for $%d."price); 
                    
SendClientMessage(playeridCOLOR_YELLOWstring); 
                    
PlayerInfo[playerid][pCash] -= price
                    
GivePlayerMoney(playerid, -price); 
                    
BizzInfo[PlayerInfo[playerid][InBusiness]][bTill] += price
                    
SaveBusiness(PlayerInfo[playerid][InBusiness]); 
                } 
                else 
                { 
                    
SendClientMessage(playeridCOLOR_GREY"You don't have enough money!"); 
                    return 
1
                } 
            } 
            else 
            { 
                
SendClientMessage(playeridCOLOR_GREY"Restricted skin!"); 
                return 
1
               } 
        } 
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)