/work command (strcmp), multi errors. [+REP]
#1

Hello everyone,
Well after I worked on /work command for my script (strcmp cmd), I got around 5 errors in 2 lines. The command code is :
pawn Код:
if(strcmp(cmd, "/work", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pJob] !=16)
            {
                SendClientMessage(playerid, COLOR_WHITE, "You are not a Woodman");
                return 1;
            }
            if(PlayerToPoint(3.0,playerid,-401.9135,-1419.8245,26.3281))
            {
                SetPlayerCheckpoint(playerid, -416.8940, -1420.9407, 24.2437, 2.0);
                return 1;
            }
            OnPlayerEnterCheckpoint(playerid)
            {
                DisablePlayerCheckpoint(playerid);
                SetPlayerCheckpoint(playerid, -396.8735, -1435.6885, 25.7266. 2.0);
                AttachPlayerObjectToPlayer(objectplayer, objectid, attachplayer, 1.5, 0.5, 1431, 0, 1.5, 2 );
            }
            OnPlayerEnterCheckpoint(playerid)
            {
                    DisablePlayerCheckpoint(playerid);
                    GivePlayerMoney(5000,playerid);
            }
        }
    }

and the compiling log is:
Код:
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(2712) : warning 204: symbol is assigned a value that is never used: "string"
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(7872) : warning 225: unreachable code
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(10738) : warning 217: loose indentation
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(10770) : warning 217: loose indentation
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(25136) : warning 217: loose indentation
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(29233) : warning 217: loose indentation
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(32061) : error 001: expected token: ";", but found "{"
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(32063) : error 001: expected token: ",", but found "."
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(32063) : error 029: invalid expression, assumed zero
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(32063) : warning 215: expression has no effect
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(32063) : error 001: expected token: ";", but found ")"
C:\Users\Server\Desktop\Fun-Generation RPG\gamemodes\Rp.pwn(32063) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Ignore the warnings above the errors.
Line 32061:
pawn Код:
OnPlayerEnterCheckpoint(playerid)
               "{"
(without the "")
and line 32063:
pawn Код:
SetPlayerCheckpoint(playerid, -396.8735, -1435.6885, 25.7266. 2.0);
Whoever help me will get +rep!

Thank you for reading.
Reply
#2

Okay so first, on top of your script, somewhere outside a callback, put this:

PHP код:
new woodmancp[MAX_PLAYERS]; 
This creates a variable 'woodmancp' for every player

Now under the OnPlayerCommandText, add your command (I fixed & added some stuff)
PHP код:
if(strcmp(cmd"/work"true) == 0)
{
    if(
IsPlayerConnected(playerid))
    {
        if(
PlayerInfo[playerid][pJob] != 16) return SendClientMessage(playeridCOLOR_WHITE"You are not a Woodman");
        if(
woodmancp[playerid] != 0) return SendClientMessage(playeridCOLOR_WHITE"You are already working");
        if(
PlayerToPoint(3.0,playerid,-401.9135,-1419.8245,26.3281)){
            
SetPlayerCheckpoint(playerid, -416.8940, -1420.940724.24372.0);
            
woodmancp[playerid] = 1;
        }
        else return 
SendClientMessage(playeridCOLOR_WHITE"You are not at the work location");
    }

Take a look at the new command, I'm sure you can figure out what's going on

Now under OnPlayerConnect callback we have to reset the woodmancp variable to ensure we're working with correct variables at all time

PHP код:
public OnPlayerConnect(playerid){
    
woodmancp[playerid] = 0;
    return 
1;

Then we move on to OnPlayerEnterCheckpoint, basically I based it on whatever the value of woodmancp is, and we change it once they enter a checkpoint! Take a look for yourself...
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(
woodmancp[playerid] == 1){
        
DisablePlayerCheckpoint(playerid);
        
SetPlayerCheckpoint(playerid, -396.8735, -1435.688525.72662.0);
        
AttachPlayerObjectToPlayer(objectplayerobjectidattachplayer1.50.5143101.5);
        
woodmancp[playerid] = 2;
    }
    else if(
woodmancp[playerid] == 2){
        
woodmancp[playerid] = 0;
        
DisablePlayerCheckpoint(playerid);
        
GivePlayerMoney(5000,playerid);
    }
    return 
1;

I hope you've been able to fix your code now, and maybe learn something too!
Hit me up with a profile message if it is still not functioning
Reply
#3

About the errors I fount one you misplaced "," with "." in the second callback SetPlayerCheckpoint around the coordinates
Reply
#4

For 32063 line.
PHP код:
SetPlayerCheckpoint(playerid, -396.8735, -1435.688525.72662.0); 
You have "." at "25.7266" and it needs to be ","

PHP код:
SetPlayerCheckpoint(playerid, -396.8735, -1435.688525.72662.0); 
Reply
#5

Quote:
Originally Posted by bgedition
Посмотреть сообщение
About the errors I fount one you misplaced "," with "." in the second callback SetPlayerCheckpoint around the coordinates
Quote:
Originally Posted by ZeMuNaC
Посмотреть сообщение
For 32063 line.
PHP код:
SetPlayerCheckpoint(playerid, -396.8735, -1435.688525.72662.0); 
You have "." at "25.7266" and it needs to be ","

PHP код:
SetPlayerCheckpoint(playerid, -396.8735, -1435.688525.72662.0); 
You guys completely missed the point that he is trying to use the OnPlayerEnterCheckpoint callback inside a callback...

Also, heck, let newbies use strcmp and one day they'll realize other command processors are way faster & easier to use and they'll make the switch Not like newbies are going to release stuff anyways!
Reply
#6

Quote:
Originally Posted by Sellize
Посмотреть сообщение
You guys completely missed the point that he is trying to use the OnPlayerEnterCheckpoint callback inside a callback...

Also, heck, let newbies use strcmp and one day they'll realize other command processors are way faster & easier to use and they'll make the switch Not like newbies are going to release stuff anyways!
Add me on skype please, farouk.alboushy1

And btw, the typo in the SetPlayerToCheckpoint, i fixed it before you say. Thanks anyway.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)