SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 20/08/2012, 10:23 AM   #1
necrobg3
Huge Clucker
 
necrobg3's Avatar
 
Join Date: Mar 2011
Location: Bulgaria
Posts: 218
Reputation: 10
Question ELEGY HELP 3!

Hey guys. I tired many times to construct that command but it don't work.
When i spawn the elegy everything is ok, i make the command for all players.
But when i exit the vehicle and type /elegy again, it gets spawned again.
I wanna make the command when anyone type /elegy again the other car gets destroyed and let spawn new car.
Here is the command.

pawn Code:
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]);
    }
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
    vehicleid[playerid] = CreateVehicle(562, X, Y, Z, A, 0, 0, 0);
    PutPlayerInVehicle(playerid, vehicleid[playerid], 0);
    return 1;
    }

+REP for the dude who help me.
__________________
necrobg3 is offline   Reply With Quote
Old 20/08/2012, 10:47 AM   #2
AliveBG
Big Clucker
 
AliveBG's Avatar
 
Join Date: Apr 2012
Location: Bulgaria
Posts: 59
Reputation: 11
Default Re: ELEGY HELP 3!

Try this:
PHP Code:
if(strcmp(cmdtext"/elegy"true) == 0)
{
    new 
FloatXFloatYFloatZFloatA;
    new 
vehicleid[MAX_PLAYERS], vehspawned[MAX_PLAYERS];
    if(
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCOLOR_RED"ERROR: You are driving a vehicle.");
    if(
vehspawned[playerid] == 1)
    {
        
DestroyVehicle(vehicleid[playerid]);
        
vehspawned[playerid] = 0;
    }
    
GetPlayerPos(playeridXYZ);
    
GetPlayerFacingAngle(playeridA);
    
vehicleid[playerid] = CreateVehicle(562XYZA000);
    
vehspawned[playerid] = 1;
    
PutPlayerInVehicle(playeridvehicleid[playerid], 0);
    return 
1;

Edit: I forgot this.
__________________
If I helped you, give me reputation. For give click here

IP: 87.120.157.105:7777
AliveBG is offline   Reply With Quote
Old 20/08/2012, 10:48 AM   #3
milanosie
High-roller
 
milanosie's Avatar
 
Join Date: Dec 2011
Location: Amsterdam, Netherlands
Posts: 1,722
Reputation: 358
Default Re: ELEGY HELP 3!

new vehicleid[MAX_PLAYERS];

Should be a global variable, so OUTSIDE of the command and placed at the TOP of your script.

And it should be

pawn Code:
if(vehicleid[playerid] != 0)
    {
        DestroyVehicle(vehicleid[playerid]);
    }
__________________
The Chat Topic of the Dutch Board Section has now over 10,000 posts! This record of 10,000 post was set after 1 year, 6 months and 7 days!
milanosie is offline   Reply With Quote
Old 20/08/2012, 07:58 PM   #4
necrobg3
Huge Clucker
 
necrobg3's Avatar
 
Join Date: Mar 2011
Location: Bulgaria
Posts: 218
Reputation: 10
Default Re: ELEGY HELP 3!

The both ways don't work. At the second way ( milanosie ) i get error: invalid function or declaration.
__________________
necrobg3 is offline   Reply With Quote
Old 20/08/2012, 11:25 PM   #5
necrobg3
Huge Clucker
 
necrobg3's Avatar
 
Join Date: Mar 2011
Location: Bulgaria
Posts: 218
Reputation: 10
Default Re: ELEGY HELP 3!

Hello? Please i really need a help.
__________________
necrobg3 is offline   Reply With Quote
Old 21/08/2012, 12:30 AM   #6
AliveBG
Big Clucker
 
AliveBG's Avatar
 
Join Date: Apr 2012
Location: Bulgaria
Posts: 59
Reputation: 11
Default Re: ELEGY HELP 3!

Sorry, this will works
PHP Code:
new vehcheid[MAX_PLAYERS], vehspawned[MAX_PLAYERS]; // as global variable
// OnPlayerConnect
vehspawned[playerid] = 0;
// OnPlayerCommandText
if(strcmp(cmdtext"/elegy"true) == 0)
{
    new 
FloatXFloatYFloatZFloatA;
    if(
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCOLOR_RED"ERROR: You are driving a vehicle.");
    if(
vehspawned[playerid] == 1)
    {
        
DestroyVehicle(vehcheid[playerid]);
        
vehspawned[playerid] = 0;
    }
    
GetPlayerPos(playeridXYZ);
    
GetPlayerFacingAngle(playeridA);
    
vehcheid[playerid] = CreateVehicle(562XYZA000);
    
vehspawned[playerid] = 1;
    
PutPlayerInVehicle(playeridvehcheid[playerid], 0);
    return 
1;

__________________
If I helped you, give me reputation. For give click here

IP: 87.120.157.105:7777
AliveBG is offline   Reply With Quote
Old 21/08/2012, 09:22 AM   #7
necrobg3
Huge Clucker
 
necrobg3's Avatar
 
Join Date: Mar 2011
Location: Bulgaria
Posts: 218
Reputation: 10
Default Re: ELEGY HELP 3!

Thanks. +REP for you.
__________________
necrobg3 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ELEGY HELP 2! necrobg3 Scripting Help 5 19/08/2012 11:59 AM
720° with elegy The_Pain Screenshots and Videos 20 11/01/2010 04:07 AM
..:: [SDK][HKS] vol.1 : Elegy Mix ::.. XxerykxX Screenshots and Videos 2 21/09/2009 05:02 PM
/elegy command (spawns an elegy) HELP, sorry for one more thread. Simmeey Help Archive 9 20/04/2009 12:48 AM


All times are GMT. The time now is 03:09 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.