whats is wrong? -
speed258 - 11.12.2013
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.
Re: whats is wrong? -
Phil_Cutcliffe - 11.12.2013
One sec..
Re: whats is wrong? - Patrick - 11.12.2013
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
Re: whats is wrong? -
speed258 - 11.12.2013
same error like mine code.
Re: whats is wrong? - Emmet_ - 11.12.2013
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;
}
Re: whats is wrong? - Patrick - 11.12.2013
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; }
|
Re: whats is wrong? -
speed258 - 11.12.2013
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
Re: whats is wrong? -
Phil_Cutcliffe - 11.12.2013
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
Re: whats is wrong? -
Noliax8 - 11.12.2013
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
Re: whats is wrong? - Patrick - 11.12.2013
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 statementStatements 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; }
|