whats is wrong?
#1

Guys i don't know what to do can you check where is problem.
Код:
stock CV(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2)
{
	AddStaticVehicle(modelid, x, y, z, angle, color1, color2);
	allcars++;
	return allcar;
}
allcar is new allcar = -1; this code help me calculate all server vehicles which are spawned, so please help me. Thanks.
Reply
#2

One sec..
Reply
#3

Your code should look something like this, try the function I edited if it's right.

pawn Код:
//variable//
new allcars = 0;

//stock function//
stock CV(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2)
    return AddStaticVehicle(modelid, x, y, z, angle, color1, color2), allcars++;

//debug, to count if the cars are right//
CMD:ccars(playerid, params[])
{
    new string[ 50 ];
   
    format( string, sizeof( string ), "Total Cars: %i", allcars ), SendClientMessage( playerid, -1, string );
    printf( "Total Cars: %i", allcars );
    return true;
}
[i]Edit: at school, written using notepad
Reply
#4

same error like mine code.
Reply
#5

Quote:
Originally Posted by speed258
Посмотреть сообщение
this code help me calculate all server vehicles which are spawned, so please help me. Thanks.
Why not do it this way?

pawn Код:
GetServerVehicles()
{
    static
        vehicles;

    vehicles = 0;

    while (vehicles < MAX_VEHICLES && GetVehicleModel(vehicles))
        ++vehicles;

    return vehicles;
}
Reply
#6

Quote:
Originally Posted by speed258
Посмотреть сообщение
same error like mine code.
What does the error say?

Not sure if this is what you want but

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
Why not do it this way?

pawn Код:
GetServerVehicles()
{
    static
        vehicles;

    vehicles = 0;

    while (vehicles < MAX_VEHICLES && GetVehicleModel(vehicles))
        ++vehicles;

    return vehicles;
}
Reply
#7

warning 219: local variable "x" shadows a variable at a preceding level
warning 219: local variable "y" shadows a variable at a preceding level
warning 219: local variable "z" shadows a variable at a preceding level
warning 213: tag mismatch
warning 213: tag mismatch
warning 213: tag mismatch
warning 203: symbol is never used: "z"
warning 203: symbol is never used: "y"
warning 203: symbol is never used: "x"

P.S actually i tried to make code which gets me last vehicleid which server creates
so i stopped after this one, and stuck in errors
Reply
#8

pawn Код:
native IsValidVehicle(vehicleid);
 
// Count vehicles
public OnPlayerCommandText(playerid,cmdtext[])
{
    if(!strcmp(cmdtext,"/countvehicles",true))
    {            
        new
            count,
            msg[60];
 
        for(new i; i < MAX_VEHICLES; i++)
        {
            if(IsValidVehicle(i)) count++;
        }
 
        format(msg, sizeof(msg), "* There are %d valid spawned vehicles on this server.", count);
        SendClientMessage(playerid, 0x33CCCCFF, msg);
        return 1;
    }
    return 0;
}
You should probably use this example from the wiki
Reply
#9

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
//stock function//
stock CV(modelid, Float, Float:y, Float:z, Float:angle, color1, color2)
return AddStaticVehicle(modelid, x, y, z, angle, color1, color2), allcars++;
Don't know, please exemple me (exemple) "return SendClientMessage(...), variable;"

thank you
Reply
#10

Quote:
Originally Posted by Noliax8
Посмотреть сообщение
Don't know, please exemple me (exemple) "return SendClientMessage(...), variable;"

thank you
It's called Multiple Actions in 1 statement, for more information read the Tips & Tricks made by Slice

Quote:
Originally Posted by Slice
Посмотреть сообщение
Multiple actions in one statement
Statements in programming are what you'd call instructions - in PAWN these statements are all separated by the semicolon ( ; ). Sometimes you want to fit code on only one line for some reason, here's how you do that:
pawn Код:
stock KickEx( playerid, reason[] )
    SendClientMessage( playerid, 0xC00000FF, "You got kicked!! Reason:" ), SendClientMessage( playerid, 0xC00000FF, reason ), Kick( playerid );
// Sends the two client messages then kicks the player.

stock DoStuff( playerid )
    return DoFirstThing( playerid ), DoSecondThing( playerid ), DoThirdThing( playerid ), DoLastThing( playerid );
// DoStuff will return what DoLastThing returns.

public OnPlayerRequestSpawn( playerid )
{
    if ( !IsPlayerLoggedIn( playerid ) )
        return SendClientMessage( playerid, 0xC00000FF, "You're not logged in!" ), 0;
    // Send the client message and return 0
   
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)