Help with this piece of code
#1

I cant believe it, I was all excited about finally completing a piece of pawno (other than the REALLY simple stuff) without any direct help and I get errors... Can you help me please?

I'm trying to write a simple script that resets a players weapons every 5 seconds unless they are in a specified zone.

under ongamemodeinit i have
Код:
SetTimer("WeaponsCheck", 5000, 1);
and at the bottom I have

http://pawno.pastebin.com/d248bc1a3

and I get this error

Код:
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\gamemodes\Sky'sStunts'nStuff.pwn(712) : error 017: undefined symbol "playerid"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\gamemodes\Sky'sStunts'nStuff.pwn(714) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

pawn Код:
forward WeaponsCheck();
public WeaponsCheck()
{
  for(new i; i < MAX_PLAYERS; i++) {
    if(IsPlayerConnected(i))
       if(!IsPlayerInArea(i,423.9233, 56.4679, 2138.4824, 1681.4557))
        ResetPlayerWeapons(i);
  }
}
Have fun
Reply
#3

Thanks that works flawlessly.

But now for the learning part...
ResetPlayerWeapons(i);
what does the i do?
Reply
#4

Quote:
Originally Posted by ThePS3Guy
Thanks that works flawlessly.

But now for the learning part...
ResetPlayerWeapons(i);
what does the i do?
Like it says,it resets players weapons.
For example you have knife in that area,make a timer, and the player will lose the weapon (in tha area)

Ecko
Reply
#5

pawn Код:
for(new i; i < MAX_PLAYERS; i++) {
    if(IsPlayerConnected(i))
       if(!IsPlayerInArea(i,423.9233, 56.4679, 2138.4824, 1681.4557))
        ResetPlayerWeapons(i);
Creates a loop for all the players, so it checks if ANYONE is outside Area 69 it resets that persons weapon etc.
Reply
#6

He asked what the 'i' did.

In that example, and plenty of others due to previous scripts using it, the definition of 'i' is used to represent that point in the 'for' loop that's being done.

and since it's going up to MAX_PLAYERS, it can also represent the playerid, without issues arising.
Reply
#7

Oh,I didn't know what did he asked.Anyway you explaned it.

Ecko
Reply
#8

ok thanks. i sort of understand how i works now..

but is there a way to fix "playerid and vehicleid" errors? I would just post my script but im determined to learn rather than get.
What I mean is, in my script I am using "if(GetVehicleModel(vehicleid) == 432, 425, 520)" under "public WeaponsVehicleCheck()" and it says

Код:
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\gamemodes\Sky'sStunts'nStuff.pwn(718) : error 017: undefined symbol "playerid"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\gamemodes\Sky'sStunts'nStuff.pwn(720) : error 017: undefined symbol "vehicleid"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\gamemodes\Sky'sStunts'nStuff.pwn(722) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
is there a way to tell it to use the cmd playerid?
Reply
#9

Quote:
Originally Posted by ThePS3Guy
ok thanks. i sort of understand how i works now..

but is there a way to fix "playerid and vehicleid" errors? I would just post my script but im determined to learn rather than get.
What I mean is, in my script I am using "if(GetVehicleModel(vehicleid) == 432, 425, 520)" under "public WeaponsVehicleCheck()" and it says

Код:
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\gamemodes\Sky'sStunts'nStuff.pwn(718) : error 017: undefined symbol "playerid"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\gamemodes\Sky'sStunts'nStuff.pwn(720) : error 017: undefined symbol "vehicleid"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\gamemodes\Sky'sStunts'nStuff.pwn(722) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
is there a way to tell it to use the cmd playerid?
maybe MAYBE this will work:

if(GetVehicleModel(vehicleid) == 432, 425, 520);
Reply
#10

thats what im asking about
i use if(GetVehicleModel(vehicleid) == 432, 425, 520); and it doesnt understand vehicleid
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)