Enter / Exit -
vIBIENNYx - 23.05.2012
So far I have this:
pawn Код:
command(enter, playerid, params[])
{
switch(arrowpickup[])
{
//
}
return 1;
}
I have the pickups declared and they display, they are also entered into the array shown below:
pawn Код:
// Arrow Array
new arrowpickup[100];
stock showarrowpickups()
{
arrowpickup[1] = CreatePickup(1318, 1, -2440.8452, 524.1761, 29.9064, -1);
arrowpickup[2] = CreatePickup(1318, 1, -2453.5320, 504.0138, 30.0802, -1);
print("Arrow Pickups loaded");
}
The error is on the "switch" line, the error is: "bensamp.pwn(944) : error 029: invalid expression, assumed zero".
Can anyone please help me? Or see as to where I have gone wrong.
Re: Enter / Exit -
ReneG - 23.05.2012
Switch statements can only be used for integers.
is a string.
Re: Enter / Exit -
vIBIENNYx - 23.05.2012
Okay, how should I turn it into an integer?
Basically, I'm trying to assign an ID to the pickup, and use the ID in the case statement rather than writing a million if statements.
Re: Enter / Exit -
Jonny5 - 23.05.2012
actually it looks like an array of ids to me.
i think this is something closer to what you want.
pawn Код:
command(enter, playerid, params[])
{
new param = strval(params);
switch(param)
{
case arrowpickup[0] :
{
//some code here
}
case arrowpickup[1] :
{
//some code here
}
}
return 1;
}
Re: Enter / Exit -
vIBIENNYx - 23.05.2012
Quote:
Originally Posted by Jonny5
actually it looks like an array of ids to me.
i think this is something closer to what you want.
pawn Код:
command(enter, playerid, params[]) { new param = strval(params); switch(param) { case arrowpickup[0] : { //some code here } case arrowpickup[1] : { //some code here } } return 1; }
|
Thank you very much, I cannot add this into my code right now but I will asap. Repped.
Re: Enter / Exit -
Jonny5 - 23.05.2012
btw have you looked at this system?
http://forum.sa-mp.com/showthread.ph...85#post1456585
makes adding these very easy!
good luck with ya mode!
~j5
Re: Enter / Exit -
vIBIENNYx - 23.05.2012
Quote:
Originally Posted by Jonny5
|
That looks good but, I'm trying to use as little includes and I would rather it be a command rather than just run into it and TP, thanks though mate ^^
Re: Enter / Exit -
SuperViper - 23.05.2012
You can't have variables as cases in a switch statement. You should save the location of the pickups in a variable and loop through it.
Re: Enter / Exit -
[ABK]Antonio - 23.05.2012
Quote:
Originally Posted by SuperViper
You can't have variables as cases in a switch statement. You should save the location of the pickups in a variable and loop through it.
|
In PAWN you can have variables as cases.
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid) //don't know why you would use a command to enter pickups
{
switch(pickupid)
{
case arrowpickup[1]:
{
//do stuff
}
case arrowpickup[2]:
{
//do stuff
}
}
}
Re: Enter / Exit -
vIBIENNYx - 23.05.2012
Quote:
Originally Posted by [ABK]Antonio
In PAWN you can have variables as cases.
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid) //don't know why you would use a command to enter pickups { switch(pickupid) { case arrowpickup[1]: { //do stuff } case arrowpickup[2]: { //do stuff } } }
|
I get two errors regarding the two cases themselves.
pawn Код:
C:\Users\Ben\Desktop\SF-RP\gamemodes\bensamp.pwn(542) : error 008: must be a constant expression; assumed zero
C:\Users\Ben\Desktop\SF-RP\gamemodes\bensamp.pwn(546) : error 008: must be a constant expression; assumed zero
Not to sure what the error is either.