Help me Please :(
#1

i got little problem

Код:
D:\data aji\Samp server\gamemodes\Adjie.pwn(452) : warning 219: local variable "id" shadows a variable at a preceding level
D:\data aji\Samp server\gamemodes\Adjie.pwn(456) : warning 213: tag mismatch
D:\data aji\Samp server\gamemodes\Adjie.pwn(452) : warning 204: symbol is assigned a value that is never used: "id"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
this Command got problem
Код:
CMD:chouse(playerid, params[])
{
    new tmp[256];
	tmp = strtok(params,Index);
	new tmp2[256];
	tmp2 = strtok(params,Index);
	if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,-1,"Use: /chouse [price] [intid]");
	new id = strval(tmp2);
	new Price = strval(tmp);
	if(Price <= 0)
	return SendClientMessage(playerid,-1,"Invalid house price. The house price must be between $"#MIN_HOUSE_PRICE" and $"#MAX_HOUSE_PRICE"");
	CreateHouse(playerid,GetFreeHouseID(),Price,id);
	SendClientMessage(playerid,-1,"House Created");
    return 1;
}
Line 452 new id = strval(tmp2);
Line 456 CreateHouse(playerid,GetFreeHouseID(),Price,id);



Thanks Before
Reply
#2

Try using sscanf,

PHP код:
CMD:chouse(playeridparams[])
{
    
    new 
Price[128];
    new 
ID[128];
    if(
sscanf(params,"ii",Price,ID) return SendClientMessage(playerid,-1,"Use: /chouse [price] [intid]");
    if(
Price <= 0) return SendClientMessage(playerid,-1,"Invalid house price. The house price must be between $"#MIN_HOUSE_PRICE" and $"#MAX_HOUSE_PRICE"");
    
CreateHouse(playerid,GetFreeHouseID(),Price,ID);
    
SendClientMessage(playerid,-1,"House Created");
    return 
1;

sscanf
Reply
#3

You probably have defined "id" globally.
Reply
#4

Quote:
Originally Posted by RyderX
Посмотреть сообщение
Try using sscanf,

PHP код:
CMD:chouse(playeridparams[])
{
    
    new 
Price[128];
    new 
ID[128];
    if(
sscanf(params,"ii",Price,ID) return SendClientMessage(playerid,-1,"Use: /chouse [price] [intid]");
    if(
Price <= 0) return SendClientMessage(playerid,-1,"Invalid house price. The house price must be between $"#MIN_HOUSE_PRICE" and $"#MAX_HOUSE_PRICE"");
    
CreateHouse(playerid,GetFreeHouseID(),Price,ID);
    
SendClientMessage(playerid,-1,"House Created");
    return 
1;

and i got this
Код:
D:\data aji\Samp server\gamemodes\Adjie.pwn(450) : error 001: expected token: ")", but found "return"
D:\data aji\Samp server\gamemodes\Adjie.pwn(451) : error 033: array must be indexed (variable "Price")
D:\data aji\Samp server\gamemodes\Adjie.pwn(452) : error 035: argument type mismatch (argument 3)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Reply
#5

Quote:
Originally Posted by Jihanz
Посмотреть сообщение
and i got this
Код:
D:\data aji\Samp server\gamemodes\Adjie.pwn(450) : error 001: expected token: ")", but found "return"
D:\data aji\Samp server\gamemodes\Adjie.pwn(451) : error 033: array must be indexed (variable "Price")
D:\data aji\Samp server\gamemodes\Adjie.pwn(452) : error 035: argument type mismatch (argument 3)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Should be like this

PHP код:
CMD:chouse(playeridparams[]) 

     
    new 
Price[128]; 
    new 
ID[128]; 
    if(
sscanf(params,"ii",Price,ID)) return SendClientMessage(playerid,-1,"Use: /chouse [price] [intid]"); 
    if(
Price <= 0) return SendClientMessage(playerid,-1,"Invalid house price. The house price must be between $"#MIN_HOUSE_PRICE" and $"#MAX_HOUSE_PRICE""); 
    
CreateHouse(playerid,GetFreeHouseID(),Price,ID); 
    
SendClientMessage(playerid,-1,"House Created"); 
    return 
1

Reply
#6

Quote:
Originally Posted by TopShooter2
Посмотреть сообщение
Should be like this

PHP код:
CMD:chouse(playeridparams[]) 

     
    new 
Price[128]; 
    new 
ID[128]; 
    if(
sscanf(params,"ii",Price,ID)) return SendClientMessage(playerid,-1,"Use: /chouse [price] [intid]"); 
    if(
Price <= 0) return SendClientMessage(playerid,-1,"Invalid house price. The house price must be between $"#MIN_HOUSE_PRICE" and $"#MAX_HOUSE_PRICE""); 
    
CreateHouse(playerid,GetFreeHouseID(),Price,ID); 
    
SendClientMessage(playerid,-1,"House Created"); 
    return 
1

and i got this
Код:
D:\data aji\Samp server\gamemodes\Adjie.pwn(451) : error 033: array must be indexed (variable "Price")
D:\data aji\Samp server\gamemodes\Adjie.pwn(452) : error 035: argument type mismatch (argument 3)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#7

Try this.

PHP код:
CMD:chouse(playeridparams[])  
{  
      
    new 
Price;  
    new 
ID;  
    if(
sscanf(params,"ii",Price,ID)) return SendClientMessage(playerid,-1,"Use: /chouse [price] [intid]");  
    if(
Price <= 0) return SendClientMessage(playerid,-1,"Invalid house price. The house price must be between $"#MIN_HOUSE_PRICE" and $"#MAX_HOUSE_PRICE"");  
    
CreateHouse(playerid,GetFreeHouseID,Price,ID);  
    
SendClientMessage(playerid,-1,"House Created");  
    return 
1;  

Reply
#8

Test it without the definitions

Код:
 if(Price <= 0) return SendClientMessage(playerid,-1,"Invalid house price. The house price must be between $X and $X");
Reply
#9

PHP код:
CMD:chouse(playeridparams[]) 

     
    new 
Price[128]; 
    new 
ID[128]; 
    if(
sscanf(params,"ii",Price,ID) return SendClientMessage(playerid,-1,"Use: /chouse [price] [intid]"); 
    
CreateHouse(playerid,GetFreeHouseID(),Price,ID); 
    
SendClientMessage(playerid,-1,"House Created"); 
    return 
1

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)