Help please!
#1

Hey guys im making a createspike code have this but i was wondering how i could get max players, as its giving errors. any help would be great and will +rep for the help.

pawn Код:
Createspike(Float:x,Float:y,Float:z,Float:Angle)
{
    for(new i = 0; i < sizeof(SpikeInfo); i++)
    {
        for(new p = 0; p < sizeof(MAX_PLAYERS); p++)
        {
            if(SpikeInfo[i][SpikeCreated] == 0)
            {
                SpikeInfo[i][SpikeCreated]=1;
                SpikeInfo[i][SpikeX]=x;
                SpikeInfo[i][SpikeY]=y;
                SpikeInfo[i][SpikeZ]=z-0.7;
                SpikeInfo[i][SpikeObject] = CreateDynamicObject(2899, x, y, z-0.88, 0, 0, Angle-90);
                SpikeInfo[i][SpikeOwner] = GetName(p);
                return 1;
            }
        }
    }
    return 0;
}
Код:
C:\Documents and Settings\SAMP\Desktop\SA-MP 0.3.7\filterscripts\Spikes1.pwn(120) : error 020: invalid symbol name ""
C:\Documents and Settings\SAMP\Desktop\SA-MP 0.3.7\filterscripts\Spikes1.pwn(120) : error 029: invalid expression, assumed zero
C:\Documents and Settings\SAMP\Desktop\SA-MP 0.3.7\filterscripts\Spikes1.pwn(120) : warning 215: expression has no effect
C:\Documents and Settings\SAMP\Desktop\SA-MP 0.3.7\filterscripts\Spikes1.pwn(120) : error 017: undefined symbol "p"
C:\Documents and Settings\SAMP\Desktop\SA-MP 0.3.7\filterscripts\Spikes1.pwn(120) : fatal error 107: too many error messages on one line
Reply
#2

PHP код:
Createspike(playerid,Float:x,Float:y,Float:z,Float:Angle)
{
    for(new 
0sizeof(SpikeInfo); i++)
      {
        if(
SpikeInfo[i][SpikeCreated] == 0)
        {
            
SpikeInfo[i][SpikeCreated]=1;
            
SpikeInfo[i][SpikeX]=x;
            
SpikeInfo[i][SpikeY]=y;
            
SpikeInfo[i][SpikeZ]=z-0.7;
            
SpikeInfo[i][SpikeObject] = CreateDynamicObject(2899xyz-0.8800Angle-90);
            
SpikeInfo[i][SpikeOwner] = GetName(playerid);
            return 
1;
        }
      }
      return 
0;

PHP код:
Createspike(playerid,Float:x,Float:y,Float:z,Float:Angle); 
Reply
#3

Your problem was at the "p" the fifth line.
Reply
#4

Thanks guy i sorted it myself thanks anyway

pawn Код:
Createspike(Float:x,Float:y,Float:z,Float:Angle)
{
    for(new i = 0; i < sizeof(SpikeInfo); i++)
    {
        //for(new p = 0; p < sizeof(MAX_PLAYERS); p++) *The Code Was Wrong*
            for(new p=0; p<MAX_PLAYERS; p++)
        {
            if(SpikeInfo[i][SpikeCreated] == 0)
            {
                SpikeInfo[i][SpikeCreated]=1;
                SpikeInfo[i][SpikeX]=x;
                SpikeInfo[i][SpikeY]=y;
                SpikeInfo[i][SpikeZ]=z-0.7;
                SpikeInfo[i][SpikeObject] = CreateDynamicObject(2899, x, y, z-0.88, 0, 0, Angle-90);
                SpikeInfo[i][SpikeOwner] = GetName(p);
                return 1;
            }
        }
    }
    return 0;
}
I have Rep'd you both
Reply
#5

Glad it working.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)