27.09.2012, 11:45
I have a tutorial which uses a series of pickups to determine what the user has to do to complete it, this system works except for one major flaw. The vehicle spawns on EVERY pickup that the user picks up inside the tutorial.
Here's the code:
Here's the code that the user needs to continue.
So, as you can see the pickups are being deleted as and when the user doesn't need them anymore.
Any ideas why the car keeps respawning?
Here's the code:
pawn Код:
// TUTORIAL PICKUPS
if(pickupid == tutorialpickup[playerid][0])
{
// Vehicle Interaction
SendClientMessage(playerid, 0xFFFFFFFF, " ");
SendClientMessage(playerid, 0xFFCC9999, "Tutorial #1: Vehicle interaction.");
SendClientMessage(playerid, 0xFFCC9999, "To interact with vehicles, walk up beside one or get into one and press 'Y' or type '/vinteract'.");
tutorialvehicle[playerid] = CreateVehicle(405, -2706.7336, 349.0867, 4.1325, 1.1084, 0, 0, -1);
SetVehicleVirtualWorld(tutorialvehicle[playerid], playerid+100);
SetVehicleParamsEx(tutorialvehicle[playerid], 0, 0, 0, 0, 0, 0, 0);
SendClientMessage(playerid, 0xFFCC9999, "To interact with the lights and engine you can use: /eon, /eoff, /lon and /loff.");
SendClientMessage(playerid, 0xFFCC9999, "To finish the tutorial you must break the window of the vehicle.");
}
if(pickupid == tutorialpickup[playerid][1])
{
// Basic Role-Play
SendClientMessage(playerid, 0xFFFFFFFF, " ");
SendClientMessage(playerid, 0xFFCC9999, "Tutorial #2: Basic Role-play.");
SendClientMessage(playerid, 0xFFCC9999, "There are several commands that you can use to enhance roleplay, these are: /me and /do");
SendClientMessage(playerid, 0xFFCC9999, "You can also try: /accent and /description to help describe your character.");
SendClientMessage(playerid, 0xFFCC9999, "Here are some examples:");
SendClientMessage(playerid, 0xC2A2DAAA, "Ben Karner holds his hand on the back of his neck, rolling his neck across his shoulders.");
SendClientMessage(playerid, 0xC2A2DAAA, "You would hear a quiet cracking sound. ((Ben Karner))");
}
if(pickupid == tutorialpickup[playerid][2])
{
// Roleplaying Injuries
SendClientMessage(playerid, 0xFFFFFFFF, " ");
SendClientMessage(playerid, 0xFFCC9999, "Tutorial #3: Role-playing Injuries.");
SendClientMessage(playerid, 0xFFCC9999, "Throughout your time in SF-RP you are bound to be shot, stabbed, punched and you might even fall over.");
SendClientMessage(playerid, 0xFFCC9999, "During these occasions and others that would cause halm to your character you must RP injuries.");
SendClientMessage(playerid, 0xFFCC9999, "You can do this by using /me's, /do's and animations.");
TutInjuriesTimer[playerid] = SetTimerEx("TutorialInjuries", 3000, false, "i", playerid);
}
if(pickupid == tutorialpickup[playerid][3])
{
// Weapons
}
if(pickupid == tutorialpickup[playerid][4])
{
// Sidejobs
}
pawn Код:
// TUTORIAL
command(continue, playerid, params[])
{
if(loggedin[playerid] == 0) return SendClientMessage(playerid, 0x66666666, "You must be logged in perform commands");
if(pInTutorial[playerid] == 0) return SendClientMessage(playerid, 0x66666666, "You are not in the tutorial.");
switch(tutorialsdone[playerid])
{
case 0:
{
SendClientMessage(playerid, 0x66666666, "You must meet the requirements for the tutorial.");
}
case 1:
{
DestroyVehicle(tutorialvehicle[playerid]);
ResetVVar(tutorialvehicle[playerid]);
SendClientMessage(playerid, 0xFFCC9999, "Thank you for finishing this part of the tutorial, please find the next pickup.");
DestroyPickup(tutorialpickup[playerid][0]);
tutorialpickup[playerid][1] = CreatePickup(1239, 8, -2706.5, 394.4166, 4.3672, playerid+100);
RemovePlayerMapIcon(playerid, pTutorialMarker[playerid]);
SetPlayerMapIcon(playerid, pTutorialMarker[playerid], -2706.5, 394.4166, 4.3672, 0, 0xFFCC9999, MAPICON_GLOBAL);
}
case 2:
{
DestroyPickup(tutorialpickup[playerid][1]);
SendClientMessage(playerid, 0xFFCC9999, "Thank you for finishing this part of the tutorial, please find the next pickup.");
tutorialpickup[playerid][2] = CreatePickup(1239, 8, -2685.5, 382.2196, 4.3672, playerid+100);
RemovePlayerMapIcon(playerid, pTutorialMarker[playerid]);
SetPlayerMapIcon(playerid, pTutorialMarker[playerid], -2685.5, 382.2196, 4.3672, 0, 0xFFCC9999, MAPICON_GLOBAL);
}
case 3:
{
DestroyPickup(tutorialpickup[playerid][2]);
SendClientMessage(playerid, 0xFFCC9999, "Thank you for finishing this part of the tutorial, please find the next pickup.");
tutorialpickup[playerid][3] = CreatePickup(1239, 8, -2685.5, 368.2350, 4.3964, playerid+100);
RemovePlayerMapIcon(playerid, pTutorialMarker[playerid]);
SetPlayerMapIcon(playerid, pTutorialMarker[playerid], -2685.5, 368.2350, 4.3964, 0, 0xFFCC9999, MAPICON_GLOBAL);
}
case 4:
{
DestroyPickup(tutorialpickup[playerid][3]);
SendClientMessage(playerid, 0xFFCC9999, "Thank you for finishing this part of the tutorial, please find the next pickup.");
tutorialpickup[playerid][4] = CreatePickup(1239, 8, -2722.25, 368.0362, 4.3970, playerid+100);
RemovePlayerMapIcon(playerid, pTutorialMarker[playerid]);
SetPlayerMapIcon(playerid, pTutorialMarker[playerid], -2722.25, 368.0362, 4.3970, 0, 0xFFCC9999, MAPICON_GLOBAL);
}
case 5:
{
DestroyPickup(tutorialpickup[playerid][4]);
SendClientMessage(playerid, 0xFFCC9999, "Thank you for finishing the entire tutorial, you will be teleported to the main world.");
SendClientMessage(playerid, 0xFFCC9999, "Where you can start role-playing, we wish you the best of luck, have fun.");
RemovePlayerMapIcon(playerid, pTutorialMarker[playerid]);
}
}
return 1;
}
// END OF TUTORIAL
Any ideas why the car keeps respawning?