Little Problem.
#1

Hey Guys, I Know I have been posting a fair bit recently, and Thanks ALOT so far. you have been really helpfull.

I Have been doing alot of Scripting and with a new command I Have hit this.

PHP код:

    
if(strcmp(cmd"/build"true) == 0)
    {
        new 
tmp[128];
        
tmp strtok(cmdtextidx);
        if(
strlen(tmp) == 0) return SendClientMessage(playeridCOLOR_GREY"USAGE: /build [buildable]"), SendClientMessage(playeridCOLOR_GREY"Objects: 1 [ Fence ]");
        if(
strval(tmp) == || PlayerInfo[playerid][pMats] == 5)) // error 029: invalid expression, assumed zero
        
{
// Fence: 1141
        
new pos:X;
        new 
pos:Y;
        new 
pos:Z;
        new 
object;
        
GetPlayerPos(strval(tmp), pos:Xpos:Ypos:Z);
        
CreateObject(objectpos:Xpos:Ypos:Z);
        }
        else 
// invalid expression, assumed zero Error
        
{
  
SendClientMessage(playerid0xFFFFFFFF"Not enough mats Buddy!");
        }
        return 
1;
    } 
The Error is:

Код:
error 022: must be lvalue (non-constant)
error 001: expected token: ";", but found ")"
rror 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Thanks in Advance
Reply
#2

You have a non matching ')' where there is the FIRST invalid expression assumed 0
Reply
#3

thanks
Reply
#4

Okay so it works now.. but The Object dosen't spawn ingame

PHP код:
    if(strcmp(cmd"/build"true) == 0)
    {
        new 
tmp[128];
        
tmp strtok(cmdtextidx);
        if(
strlen(tmp) == 0) return SendClientMessage(playeridCOLOR_GREY"USAGE: /build [buildable]"), SendClientMessage(playeridCOLOR_GREY"Objects: 1 [ Fence ]");
        if(
strval(tmp) == || PlayerInfo[playerid][pMats] == 5)
        {
// Fence: 1141
        
new Float:X;
        new 
Float:Y;
        new 
Float:Z;
        
GetPlayerPos(strval(tmp), Float:XFloat:YFloat:Z);
        
CreateObject(3095pos:X+1pos:Ypos:Z+1000100);
        
SendClientMessage(playeridCOLOR_GREY"Built!");
        }
        else
        {
        
SendClientMessage(playerid0xFFFFFFFF"Not Enough Mats!");
        }
        return 
1;
    } 
Reply
#5

Quote:
Originally Posted by Grant Johnston
Посмотреть сообщение
Okay so it works now.. but The Object dosen't spawn ingame

PHP код:
    if(strcmp(cmd"/build"true) == 0)
    {
        new 
tmp[128];
        
tmp strtok(cmdtextidx);
        if(
strlen(tmp) == 0) return SendClientMessage(playeridCOLOR_GREY"USAGE: /build [buildable]"), SendClientMessage(playeridCOLOR_GREY"Objects: 1 [ Fence ]");
        if(
strval(tmp) == || PlayerInfo[playerid][pMats] == 5)
        {
// Fence: 1141
        
new Float:X;
        new 
Float:Y;
        new 
Float:Z;
        
GetPlayerPos(strval(tmp), Float:XFloat:YFloat:Z);
        
CreateObject(3095pos:X+1pos:Ypos:Z+1000100);
        
SendClientMessage(playeridCOLOR_GREY"Built!");
        }
        else
        {
        
SendClientMessage(playerid0xFFFFFFFF"Not Enough Mats!");
        }
        return 
1;
    } 
Ehm, can I see the type/tag definition of 'pos:', try instead:

pawn Код:
if(strcmp(cmd, "/build", true) == 0)
    {
        new tmp[128];
        tmp = strtok(cmdtext, idx);
        if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /build [buildable]"), SendClientMessage(playerid, COLOR_GREY, "Objects: 1 [ Fence ]");
        if(strval(tmp) == 1 || PlayerInfo[playerid][pMats] == 5)
        {
// Fence: 1141
        new Float:X;
        new Float:Y;
        new Float:Z;
        GetPlayerPos(playerid, X, Y, Z); // Why were you getting the position of strval(tmp), that's only an 1/0 parameter :P
        CreateObject(3095, X+1, Y, Z+1, 0, 0, 0, 100);
        SendClientMessage(playerid, COLOR_GREY, "Built!");
        }
        else
        {
        SendClientMessage(playerid, 0xFFFFFFFF, "Not Enough Mats!");
        }
        return 1;
    }
Reply
#6

pawn Код:
if(strcmp(cmd, "/build", true) == 0)
    {
        new tmp[128];
        tmp = strtok(cmdtext, idx);
        if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /build [buildable]"), SendClientMessage(playerid, COLOR_GREY, "Objects: 1 [ Fence ]");
        if(strval(tmp) == 1 || PlayerInfo[playerid][pMats] == 5)
        {
// Fence: 1141
        new Float:X;
        new Float:Y;
        new Float:Z;
        GetPlayerPos(playerid, X, Y, Z);
        CreateObject(strval(tmp), X+1, Y, Z+1, 0, 0, 0, 100);
        SendClientMessage(playerid, COLOR_GREY, "Built!");
        }
        else
        {
        SendClientMessage(playerid, 0xFFFFFFFF, "Not Enough Mats!");
        }
        return 1;
    }
Reply
#7

Instead of writing a whole new Thread I will just Comment here. :P

Im trying to make a random spawn system
But I Need it to Randomly Choose the Spawn Coordinates.
I Have some Code
..


Код:
SetPlayerPos(playerid,coordx[random(sizeof(coordx))],coordy[random(sizeof(coordy))],coordz[random(sizeof(coordz))]
Basically Its Choosing them randomly so Im getting destroyed by World Boundaries. How Can I Make the system so It chooses one column And they all Choose the same coloumn of there own Coordinate Variables.

Hard to explain but here it is.

PHP код:
new coordx[] = // coordx
{
    
2010.1997,
    
2217.0286,
    
2008.1178,
    
1652.7507,
    
2019.7411
};
new 
coordy[] =
{
    
1158.7738,
    
2373.9978,
    
930.7737,
    
1652.7507,
    
1158.4047
};
new 
coordz[] =
{
   
10.8203,
   
10.6719,
   
10.8203,
   
10.6669,
   
10.6585
}; 
So when one is chosen, from one Row. They all choose the same row.

So Far Im Just getting destroyed by World Boundaries because they are random coords. :P
Reply
#8

Quote:
Originally Posted by Grant Johnston
Посмотреть сообщение
Instead of writing a whole new Thread I will just Comment here. :P

Im trying to make a random spawn system
But I Need it to Randomly Choose the Spawn Coordinates.
I Have some Code
..


Код:
SetPlayerPos(playerid,coordx[random(sizeof(coordx))],coordy[random(sizeof(coordy))],coordz[random(sizeof(coordz))]
Basically Its Choosing them randomly so Im getting destroyed by World Boundaries. How Can I Make the system so It chooses one column And they all Choose the same coloumn of there own Coordinate Variables.

Hard to explain but here it is.

PHP код:
new coordx[] = // coordx
{
    
2010.1997,
    
2217.0286,
    
2008.1178,
    
1652.7507,
    
2019.7411
};
new 
coordy[] =
{
    
1158.7738,
    
2373.9978,
    
930.7737,
    
1652.7507,
    
1158.4047
};
new 
coordz[] =
{
   
10.8203,
   
10.6719,
   
10.8203,
   
10.6669,
   
10.6585
}; 
So when one is chosen, from one Row. They all choose the same row.

So Far Im Just getting destroyed by World Boundaries because they are random coords. :P
Instead of creating 3 times 3 random numbers, create first a random number (The row number), then set the pos.

Код:
new rand = random(sizeof(coordx));
SetPlayerPos(playerid,coordx[rand],coordy[rand],coordz[rand]);
Reply
#9

Im sorry, I dont understand what you are saying? :P
(( I also Tried that code you pasted. and I still get destroyed by the world boundaries. ))
Reply
#10

Nevermind, I Got it to work :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)