Elegy Help
#1

Hey guys. I own a command, who spawns elegy when you type /elegy .
The problem is when another player types it, mine get destroyed or i think the command spawn only one elegy.
Can anyone please give a look at this?
Here is the code.

Код:
    if (strcmp("/elegy", cmdtext, true, 10) == 0)
    {
    
    new Float: X, Float: Y, Float: Z, Float: A;
    static vehicleid;
    
	if(IsPlayerInAnyVehicle(playerid))  return SendClientMessage(playerid, COLOR_RED, "ERROR: You are driving a vehicle.");
    if(vehicleid)
	{
    DestroyVehicle(vehicleid);
    }
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
    PutPlayerInVehicle(playerid, (vehicleid = CreateVehicle(562, X, Y, Z, A, 0, 0, 0)), 0);
    return 1;
    }
+Rep for the dude who help me.
Reply
#2

pawn Код:
if (strcmp("/elegy", cmdtext, true, 10) == 0)
{
    new Float: X, Float: Y, Float: Z, Float: A;
    new vehicleid[MAX_PLAYERS];
    if(IsPlayerInAnyVehicle(playerid))  return SendClientMessage(playerid, COLOR_RED, "ERROR: You are driving a vehicle.");
    if(vehicleid)
    {
        DestroyVehicle(vehicleid);
    }
    vehicleid[playerid] = CreateVehicle(562, X, Y, Z, A, 0, 0, 0)
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
    PutPlayerInVehicle(playerid, vehicleid[playerid], 0);
    return 1;
}
Actually, what if(vehicleid) for?
Reply
#3

I don't get friend online to test it multiply now. Later i will test it and +rep you if it works.
Reply
#4

Quote:
Originally Posted by IceMeteor
Посмотреть сообщение
pawn Код:
if (strcmp("/elegy", cmdtext, true, 10) == 0)
{
    new Float: X, Float: Y, Float: Z, Float: A;
    new vehicleid[MAX_PLAYERS];
    if(IsPlayerInAnyVehicle(playerid))  return SendClientMessage(playerid, COLOR_RED, "ERROR: You are driving a vehicle.");
    if(vehicleid)
    {
        DestroyVehicle(vehicleid);
    }
    vehicleid[playerid] = CreateVehicle(562, X, Y, Z, A, 0, 0, 0)
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
    PutPlayerInVehicle(playerid, vehicleid[playerid], 0);
    return 1;
}
Actually, what if(vehicleid) for?
Oh i can't compile it.

pawn Код:
error 033: array must be indexed (variable "vehicleid")
error 035: argument type mismatch (argument 1)
Here is the variable.

pawn Код:
new vehicleid[MAX_PLAYERS];
The argument type mismatch (argument 1) is on this line.

pawn Код:
DestroyVehicle(vehicleid);
I dont see where is the problem?
Reply
#5

Hello? Please i really need some help.
Reply
#6

pawn Код:
DestroyVehicle(vehicleid[playerid]);
please, next time just read those error messages and use simple logic to fix something like that..

also this

pawn Код:
if(vehicleid[playerid] != 0)
Reply
#7

Sorry, forget to array it
pawn Код:
if (strcmp("/elegy", cmdtext, true, 10) == 0)
{
    new Float: X, Float: Y, Float: Z, Float: A;
    new vehicleid[MAX_PLAYERS];
    if(IsPlayerInAnyVehicle(playerid))  return SendClientMessage(playerid, COLOR_RED, "ERROR: You are driving a vehicle.");
    if(vehicleid[playerid])
    {
        DestroyVehicle(vehicleid[playerid]);
    }
    vehicleid[playerid] = CreateVehicle(562, X, Y, Z, A, 0, 0, 0)
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
    PutPlayerInVehicle(playerid, vehicleid[playerid], 0);
    return 1;
}
Reply
#8

Thanks guys. +Rep for you both.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)